//第一种
UIColor *color = [UIColor whiteColor];
_userName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];
//第二种
[_userName setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
修改UITextfield的Placeholder字体的颜色
最新推荐文章于 2021-07-05 18:28:58 发布
本文介绍了在iOS开发中使用两种不同方法来改变UITextField控件中占位符的颜色,第一种方法通过NSAttributedString设置占位符属性,第二种方法则是直接设置_placeholderLabel的textColor属性。
1705

被折叠的 条评论
为什么被折叠?



