iOS 修改textField的placeholder的字体颜色、大小

来源:互联网 发布:windows系统编程 pdf 编辑:程序博客网 时间:2024/04/28 23:03

1.

textField.placeholder =@"用户名";

[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];

2.

UIColor *color = [UIColor whiteColor];

_userName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];



0 0
原创粉丝点击