首页 > 技术文章 > iOS学习-UITextField设置placeholder的颜色

Zsmile 2015-01-05 10:47 原文

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

 

推荐阅读