UIBezierPath+YYAdd的学习

UIBezierPath+YYAdd的学习_第1张图片
图片来之网络

文字画图

+ (nullable UIBezierPath *)bezierPathWithText:(NSString *)text font:(UIFont *)font;

提供了一个将字符串绘画到view上,而不是采用UILabel的形式。
效果:


UIBezierPath+YYAdd的学习_第2张图片
绘画文字

这些文字是使用Bezier画的。

使用

新建UIView,重载方法drawRect:,

- (void)drawRect:(CGRect)rect
{
    [super drawRect:rect];

    UIBezierPath *bezier = [UIBezierPath bezierPathWithText:@"这个是怎么使用的啊" font:[UIFont systemFontOfSize:30.0f]];


    [bezier setLineWidth:2.0f];
    [[UIColor cyanColor] setStroke];
    [bezier stroke];
}

这样做的原因应该为,减少视图的层级,提高页面的性能。

// END

你可能感兴趣的:(UIBezierPath+YYAdd的学习)