绘画字符串

  CGContextRef context = UIGraphicsGetCurrentContext();//获取绘画上下文

    

    UIColor *color = [UIColorcolorWithRed:0.8green:0.2blue:0.3alpha:0.9];

    

    CGColorRef aCGColor = color.CGColor;//设置绘画颜色

    

    CGContextSetFillColor(context, CGColorGetComponents(aCGColor));//绘画的填充颜色

    

    CGContextSetFlatness(context, 1);//设置绘画平整度

    

    CGContextSetFontSize(context, 20.0f);//设置大小

    

    CGContextSetCharacterSpacing(context, 5.0f);//设置字符之间的间距

   

    CGContextFillRect(context, CGRectMake(0.0f, 0.0f, 320.0f, 480.0f));//填充的区域大小

  

    CGContextSetStrokeColor(context, CGColorGetComponents([UIColoryellowColor].CGColor));//设置线框的颜色

 

    NSString *str = @"HELLO";

    

    NSMutableAttributedString *str0 = [[NSMutableAttributedStringalloc ]initWithString:str];

    

    

    [str0 drawWithRect:CGRectMake(100.0f, 200.0f, 100.0f, 30.0f) options:NSStringDrawingUsesDeviceMetricscontext:nil];//字符串自己的放法进行绘画

原文地址:https://www.cnblogs.com/leevaboo/p/3549499.html