![](https://img.haomeiwen.com/i1534405/0fb1d275fd0910b4.jpg)
文字画图
+ (nullable UIBezierPath *)bezierPathWithText:(NSString *)text font:(UIFont *)font;
提供了一个将字符串绘画到view上,而不是采用UILabel的形式。
效果:
![](https://img.haomeiwen.com/i1534405/2da2a113f7a2c5c8.png)
这些文字是使用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
网友评论