iOS学习-UITextField设置placeholder的颜色

时间:2023-03-08 20:14:45
UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
text.borderStyle = UITextBorderStyleRoundedRect; NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"密码"];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(, attributedStr.length)];
text.attributedPlaceholder = attributedStr; [self.view addSubview:text];