最新下载
热门教程
- 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; }
相关文章
- 地狱即我们符文怎么装备 符文系统与技能解锁指南 09-17
- 萤火突击兑换码在哪输入 兑换码免费领取使用位置一览 09-17
- 无主之地4专业领域成就怎么达成 专业领域成就解锁攻略 09-17
- 英雄联盟手游奈德丽技能怎么加-狂野女猎手技能加点顺序 09-17
- 无主之地4粒粒皆辛苦成就怎么达成 粒粒皆辛苦成就解锁攻略 09-17
- 地狱即我们怎么装备武器 双武器配置与切换指南 09-17