- //第一种
- UIColor *color = [UIColor whiteColor];
- _userName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];
- //第二种
- [_userName setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
修改UITextfield的Placeholder字体的颜色
最新推荐文章于 2023-12-01 09:13:58 发布
本文介绍了两种在iOS开发中设置UITextField占位符颜色的方法。第一种方法通过NSAttributedString设置颜色属性,第二种方法直接通过_keyplaceholderLabel的textColor属性进行设置。
588

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



