iOS修改UITextField的Placeholder字体颜色

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

 

第一种: 

UIColor *color = [UIColor whiteColor];

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

 

第二种: 

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

  

你可能感兴趣的:(iOS修改UITextField的Placeholder字体颜色)