zoukankan      html  css  js  c++  java
  • 修改UITextField Placeholder的颜色

    修改UITextField Placeholder的颜色

    • 1 第一种情况只是修改颜色等文字属性

      • 创建属性字典
           NSDictionary *attrsDic = @{ NSForegroundColorAttributeName : [UIColor colorWithRed:106/255.0 green:114/255.0 blue:117/255.0 alpha:1],NSFontAttributeName:[UIFont systemFontOfSize:15] };
        
      • 创建属性字符串
           NSAttributedString *str = [[NSAttributedString alloc] initWithString:@"anything" attributes:attrsDic];
        
      • 赋值给textfield的attributedPlaceholder属性
           _txt.attributedPlaceholder = str;	
        
    • 2 第二种情况改颜色和Placeholder位置

      • 继承UITextField

      • 重写drawPlaceholderInRect:方法

      • 设置颜色和位置等

          [colour setFill];
          rect = CGRectMake(0, 0, 0, 0);//修改位置
          [_txtOldPassWord.placeholder drawInRect:rect withFont:_txtOldPassWord.font lineBreakMode:NSLineBreakByTruncatingTail alignment:_txtOldPassWord.textAlignment];
  • 相关阅读:
    grafana邮箱配置
    grafana集群配置
    CentOS7 配置OOM监控报警
    Mycat使用配置实践
    CentOS7安装JAVA环境
    CentOS7安装MYCAT中间件
    CentOS7安装MySQL5.6
    Mockingbird
    堆的建立与功能实现
    Matlab解决线性规划问题
  • 原文地址:https://www.cnblogs.com/myqiqiang/p/4224459.html
Copyright © 2011-2022 走看看