首页 > 技术文章 > 修改UITextfield的Placeholder字体的颜色

liuyongfa 2018-08-22 17:05 原文

    //两种办法
    //attributedPlaceholder
    self.usernameTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"xxx" attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}];
    
    //KVO
    [self.usernameTextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

 

推荐阅读