美文网首页
IOS中设置UITextField的placeholder的字体

IOS中设置UITextField的placeholder的字体

作者: 缘來諟夢 | 来源:发表于2021-11-11 18:24 被阅读0次

第一种方式:
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

相关文章

网友评论

      本文标题:IOS中设置UITextField的placeholder的字体

      本文链接:https://www.haomeiwen.com/subject/zpsgzltx.html