![修改UITextfield的Placeholder字体的颜色 修改UITextfield的Placeholder字体的颜色](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"修改UITextField的placeholder字体颜色";
UITextField *textTF=[[UITextField alloc]initWithFrame:CGRectMake(20,130,300,30)];
textTF.placeholder=@"修改UITextField的placeholder字体颜色";
// // 一种方式
// [textTF setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
// 第二种方式
textTF.attributedPlaceholder=[[NSAttributedString alloc]initWithString:@"修改UITextField的placeholder字体颜色" attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}];
[self.view addSubview:textTF];
}