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部分颜色的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 鼠标事件在浏览器的差异
- 下一篇: (九)使用图像数据