0
点赞
收藏
分享

微信扫一扫

iOS UILabel 文本颜色设置

芒果六斤半 2022-10-25 阅读 57


0x01 这也需要讨论?

不就是 ​​label.textColor = [UIColor redColor];​

0x02 另外的方法呢?

用​​setValue:forKey:​​​​[label setValue:[UIColor greenColor] forKey:@"textColor"];​

0x03 还有吗?

用​​performSelector:withObject:​

​[label3 performSelector:@selector(setTextColor:) withObject:[UIColor blueColor]];​

0x04 其实还有

​[label setValue:[UIColor blueColor] forKey:@"color"];​​​​[label performSelector:@selector(setColor:) withObject:[UIColor blueColor]];​

对应的方法:​​setColor:​​​ 虽然系统没提供出来
但内部是支持的

0x05 更多

测试过​​UITextField​​​、​​UITextView​​​ 不支持方法:​​setColor:​

看来是​​UILabel​​独有的

一行代码搞定视图圆角

​​https://github.com/xjh093/JHViewCorner​​


举报

相关推荐

0 条评论