IOS-OC 修改UITextField的Placeholder字体颜色

来源:互联网 发布:c语言贴吧 编辑:程序博客网 时间:2024/05/16 11:57


这个问题在蓝牙项目中遇到的,主要是登录界面的UI设计是需要设置Placeholder字体颜色

就进行了搜索


    // 文本框UI

    _mobileTF.attributedPlaceholder = [[NSAttributedStringalloc]initWithString:@"请输入手机号"attributes:@{NSForegroundColorAttributeName: [UIColorwhiteColor]}];


    _pswTF.attributedPlaceholder = [[NSAttributedStringalloc]initWithString:@"请输入密码"attributes:@{NSForegroundColorAttributeName: [UIColorwhiteColor]}];



//  还有一个是借鉴网友的 

    [_pswTF setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"]; 

0 0