修改textFieldplaceholder字体颜色和大小

来源:互联网 发布:教师网络研修日志 编辑:程序博客网 时间:2024/06/13 08:10

  修改textFieldplaceholder字体颜色和大小

    textField.placeholder = @"请输入用户名";

    [textFieldsetValue:[UIColor grayColor]forKeyPath:@"_placeholderLabel.textColor"];

    [textFieldsetValue:[UIFont systemFontOfSize:14]forKeyPath:@"_placeholderLabel.font"];

 

    NSMutableAttributedString *placeholder =[[NSMutableAttributedStringalloc]initWithString:@"手机号"];

    [placeholdersetAttributes:@{NSForegroundColorAttributeName:[UIColorwhiteColor],

                                 NSFontAttributeName:[UIFontsystemFontOfSize:14]}range:NSMakeRange(0,1)];

    self.phoneTextfield.attributedPlaceholder =placeholder;


原创粉丝点击