代码改变世界

修改UITextfield的Placeholder字体的颜色

2018-08-22 17:05  法子  阅读(440)  评论(0编辑  收藏  举报
    //两种办法
    //attributedPlaceholder
    self.usernameTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"xxx" attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}];
    
    //KVO
    [self.usernameTextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];