iOS修改UITextField的Placeholder字体颜色

 修改UITextField的Placeholder字体颜色有一下两张方式可以达到效果。

 

第一种: 

UIColor *color = [UIColor whiteColor];

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

 

第二种: 

[textfield setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];

  

posted @ 2016-01-13 16:44  大雨不晴  阅读(305)  评论(0编辑  收藏  举报