iOS学习-UITextField设置placeholder的颜色

UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(50, 200, 200, 40)];
text.borderStyle = UITextBorderStyleRoundedRect;
    
NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"密码"];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, attributedStr.length)];
text.attributedPlaceholder = attributedStr;
    
[self.view addSubview:text];
原文地址:https://www.cnblogs.com/Zsmile/p/4202994.html