UITextField设置placeholder颜色

方式1:

        _codeTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码(4位数字)" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:kTextLightGray]}];

方式2:kvc方式

        _phoneTextField.placeholder = @"请输入手机号码";

        [_phoneTextField setValue:[UIColor colorWithHex:kTextLightGray] forKeyPath:@"_placeholderLabel.textColor"];


你可能感兴趣的:(UITextField设置placeholder颜色)