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];

 

相关文章:

  • 2021-12-28
  • 2022-02-08
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2022-02-09
  • 2022-02-18
  • 2022-03-02
  • 2022-01-21
  • 2022-03-01
  • 2021-11-18
  • 2022-01-17
相关资源
相似解决方案