最新下载
热门教程
- 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;
}
相关文章
- 杖剑传说星霜盛典活动有哪些内容 12-19
- B站免费直连入口最新-B站极速进入官方通道 12-19
- nexusmods官网入口-nexusmods最新官网地址直达 12-19
- 燕云十六声怪盗一只鹅怎么玩 12-19
- 恋与深空绒趣派对活动有什么内容 12-19
- 漫蛙2漫画官方正版下载入口-漫蛙2漫画官方正版免费下载入口 12-19
