首页 > 代码库 > iOS学习-UITextField设置placeholder的颜色

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

 

iOS学习-UITextField设置placeholder的颜色