首页 > 系统 > iOS > 正文

iOS基于 UILabel实现文字添加描边功能

2019-10-21 18:39:33
字体:
来源:转载
供稿:网友

可以达到文字描一圈黑边的效果:

iOS,UILabel,文字,描边

继承UILabel以后重载drawTextInRect:

- (void)drawTextInRect:(CGRect)rect {   CGSize shadowOffset = self.shadowOffset;  UIColor *textColor = self.textColor;    CGContextRef c = UIGraphicsGetCurrentContext();   CGContextSetLineWidth(c, 1);   CGContextSetLineJoin(c, kCGLineJoinRound);    CGContextSetTextDrawingMode(c, kCGTextStroke);   self.textColor = [UIColor whiteColor];   [super drawTextInRect:rect];   CGContextSetTextDrawingMode(c, kCGTextFill);   self.textColor = textColor;   self.shadowOffset = CGSizeMake(0, 0);   [super drawTextInRect:rect];    self.shadowOffset = shadowOffset; }

总结

以上所述是小编给大家介绍的iOS基于 UILabel实现文字添加描边功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对VEVB武林网网站的支持!


注:相关教程知识阅读请移步到IOS开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表