最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS基于 UILabel实现文字添加描边功能
时间:2022-06-26 05:45:26 编辑:袖梨 来源:一聚教程网
可以达到文字描一圈黑边的效果:
继承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;
}
相关文章
- QQ经典版app最新版本下载-QQ经典版app官方正版iOS苹果版下载入口 03-14
- picacg哔咔下载入口-PicACG官方导航 03-14
- 番茄免费全本小说畅读-番茄免费全本小说完结畅读 03-14
- 小米云服务入口在哪-小米云服务官网登录地址详解 03-14
- 漫蛙漫画官方登录入口-漫蛙2漫画app免费下载 03-14
- picacg哔咔注册验证?2026picacg哔咔一键注册指南 03-14
