iOS 改变UILabel部分颜色
//协议
UILabel *xieLabel = [[UILabel alloc] init];
xieLabel.textColor = TextGrayColor;
xieLabel.font = [UIFont systemFontOfSize:12];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"我已阅读并同意《存工资服务协议》"];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, 7)];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(7, string.length - 7)];
xieLabel.attributedText = string;
xieLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *xieyitap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(xiyiAction)];
[xieLabel addGestureRecognizer:xieyitap];
转载于:https://www.cnblogs.com/iOS-mt/p/6043136.html
《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读总结
以上是生活随笔为你收集整理的iOS 改变UILabel部分颜色的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 鼠标事件在浏览器的差异
- 下一篇: (九)使用图像数据