第一种方式:
KVC的方式
textField.placeholder = @"username is in here!";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
第二种方式:
设置 attributedPlaceholder属性
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"搜索" attributes:
@{NSForegroundColorAttributeName:[UIColor grayColor],
NSFontAttributeName:[UIFont boldSystemFontOfSize:12]}
];
searchTextField.attributedPlaceholder = attrString;
————————————————
版权声明:本文为CSDN博主「北海之灵」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xukongjing1/article/details/80999736
网友评论