最新下载
热门教程
- 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;
}
相关文章
- rhino如何把曲线变成面 08-03
- 漫蛙漫画官网APP下载-漫蛙动漫APP免费下载地址 08-03
- ktown4u中文官网登录入口-ktown4u网页版地址 08-03
- ps如何设计红色的圆形按钮 08-03
- AE如何给图片添加移动光晕动画 08-03
- Chrome浏览器广告屏蔽插件推荐与操作做法 08-03
