首页 > 其他 > 详细

如何更改UITextField 的placeholder 的字体颜色

时间:2016-04-08 14:26:14      阅读:235      评论:0      收藏:0      [点我收藏+]
storyboard 中这样设置
技术分享

具体步骤:

1.在User Defined Runtime Attributes中添加一个Key。

2.输入Key Path(这里我们输入_placeholderLabel.textColor)。

3.选择Type,有很多种(这里我们选择Color)

 
4.设置Value(这里出现的是颜色的选择面板,选择想要的颜色即可)。
 
 
纯代码的话这样子就 OK 啦
//textField的placeholder的背景色更改第一种颜色
    _userNameTxf.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
    //第二种方法
    [_userNameTxf setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel..textColor"];

如何更改UITextField 的placeholder 的字体颜色

原文:http://www.cnblogs.com/sandyzhang/p/5367705.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!