码迷,mamicode.com
首页 > 其他好文 > 详细

修改UITextfield的Placeholder字体的颜色

时间:2016-06-23 09:58:26      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad

{

    [super viewDidLoad];

 

    self.title=@"修改UITextFieldplaceholder字体颜色";

 

    UITextField *textTF=[[UITextField alloc]initWithFrame:CGRectMake(20,130,300,30)];

    textTF.placeholder=@"修改UITextFieldplaceholder字体颜色";

 

//    // 一种方式

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

 

    // 第二种方式

    textTF.attributedPlaceholder=[[NSAttributedString alloc]initWithString:@"修改UITextFieldplaceholder字体颜色" attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}];

 

    [self.view addSubview:textTF];

}

修改UITextfield的Placeholder字体的颜色

标签:

原文地址:http://www.cnblogs.com/yhj1787354782/p/5609537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!