修改UITextfield的Placeholder字体的颜色

暂时我知道的有2种方式

 

第一种

    UITextField *inviteCodeTextFiled = [[UITextField alloc]init];
    inviteCodeTextFiled.placeholder = @"请输入邀请码";
    [inviteCodeTextFiled setValue:k999999color forKeyPath:@"_placeholderLabel.textColor"];

第二种      
 

    UITextField *inviteCodeTextFiled = [[UITextField alloc]init];
   
 NSMutableAttributedString *placeHolder = [[NSMutableAttributedString alloc]initWithString: @"请输入邀请码"];
    [placeHolder addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#999999" alpha:1] range:NSMakeRange(0, placeHolder.length)];
    
    inviteCodeTextFiled.attributedPlaceholder = placeHolder;

 

你可能感兴趣的:(修改UITextfield的Placeholder字体的颜色)