最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS基于 UILabel实现文字添加描边功能
时间:2018-10-12 编辑:猪哥 来源:一聚教程网
可以达到文字描一圈黑边的效果:
继承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; }
相关文章
- scrollview tableView嵌套解决方案代码示例 09-01
- ios16怎么开启电量百分比显示 08-13
- iOS16如何删除自定义锁屏 06-08
- IOS16怎么一键提取图片中内容 06-08
- iOS16如何一键合并重复联系人 06-08
- IOS16联系人头像设置方法 06-08