iOS修改textField的placeholder的字体颜色
2017-10-21 13:47
531 查看
一、iOS6.0以后提供的方法为self.textField.attributedPlaceholder =
attrString;提供可变字符串就行。
NSAttributedString *attrString = [[NSAttributedString
alloc] initWithString:@"请输入占位文字" attributes:
@{NSForegroundColorAttributeName:[UIColor
cyanColor],
NSFontAttributeName:self.textField.font
}];
self.textField.attributedPlaceholder = attrString;
二、通过KVC修改placeholder的颜色。
[self.textField
setValue:[UIColor
cyanColor] forKeyPath:@"_placeholderLabel.textColor"];
attrString;提供可变字符串就行。
NSAttributedString *attrString = [[NSAttributedString
alloc] initWithString:@"请输入占位文字" attributes:
@{NSForegroundColorAttributeName:[UIColor
cyanColor],
NSFontAttributeName:self.textField.font
}];
self.textField.attributedPlaceholder = attrString;
二、通过KVC修改placeholder的颜色。
[self.textField
setValue:[UIColor
cyanColor] forKeyPath:@"_placeholderLabel.textColor"];
相关文章推荐
- ios修改textField的placeholder的字体颜色和大小
- ios修改textField的placeholder的字体颜色、大小
- ios使用 KVC 修改textField的placeholder的字体颜色和大小
- ios修改textField的placeholder的字体颜色、大小
- ios中修改TextField的placeholder的字体颜色和大小
- iOS 修改textField的placeholder的字体颜色、大小
- iOS 修改TextField中的placeholder字体大小和颜色
- ios修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色大小
- ios修改textField的placeholder的字体颜色、大小
- iOS 修改textField的placeholder的字体颜色
- ios修改textField的placeholder的字体颜色、大小
- ios设置字体-黑体,加粗等 修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色和大小
- iOS修改textField的placeholder的字体颜色大小
- ios修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色、大小
- ios修改textField的placeholder的字体颜色大小