如图,密码框是默认的占位文字的颜色,手机号是我们修改过后的。
代码如下:
// 占位文字属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:@"手机号" attributes:attrs];
self.phoneField.attributedPlaceholder = placeholder;
本文介绍如何在 iOS 开发中通过代码设置密码框的占位文字颜色,展示了一段使用 NSAttributedString 对 UITextField 的 placeholder 属性进行自定义颜色设置的示例。
1万+

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



