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

继承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实现文字添加描边功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
继续阅读与本文标签相同的文章
-
阿里云服务器突发性能实例t5配置性能使用场景及注意事项
2026-05-18栏目: 教程
-
Square为澳大利亚餐馆提供定制平台!
2026-05-18栏目: 教程
-
711便利店:日本计划关店1000家,母公司将裁员3000人
2026-05-18栏目: 教程
-
阿里云服务器共享型实例xn4 n4 性价比高适合个人博客 中小型网站
2026-05-18栏目: 教程
-
QQ上这3个隐藏功能,“偷偷”告诉谁在暗恋你,不准不要你钱
2026-05-18栏目: 教程
