UITextField占位文字颜色-attributedPlaceholder

来源:互联网 发布:java重写和重载的区别 编辑:程序博客网 时间:2024/06/07 15:11

这里写图片描述
如图,密码框是默认的占位文字的颜色,手机号是我们修改过后的。
代码如下:

// 占位文字属性    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];    NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:@"手机号" attributes:attrs];    self.phoneField.attributedPlaceholder = placeholder;
0 0