用CoreGraphics方式进行绘制
新建一个类继承自UILabel,重写- (void)drawRect:(CGRect)rect方法
- (void)drawRect:(CGRect)rect{
CGContextRef context = UIGraphicsGetCurrentContext();
//线宽
CGContextSetLineWidth(context, 0.5);
//线条样式
CGContextSetLineJoin(context, kCGLineJoinRound);
//绘制模式
CGContextSetTextDrawingMode(context, kCGTextStroke);
//文字边框颜色
self.textColor = [UIColor greenColor];
//橙色空心字
[super drawTextInRect:rect];
//绘制模式
CGContextSetTextDrawingMode(context, kCGTextFill);
//文字填充颜色
self.textColor = [UIColor clearColor];
//白色实心字
[super drawTextInRect:rect];
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。