【问题标题】:Placeholder color in Dark mode from Storyboard情节提要中深色模式下的占位符颜色
【发布时间】:2020-01-03 10:03:06
【问题描述】:

我想通过从用户定义的运行时属性设置键路径值来更改占位符颜色并分配自定义颜色,但它对占位符颜色没有影响 我设置的值如下

请帮助我从故事板而不是代码中需要这个

【问题讨论】:

  • PlaceholderLabel 是标签吗?
  • Placeholder 是 Textfield @jawadAli 中的一个标签
  • 使用 placeholderLabel.textColor 而不是 _placeholderLabel.textColor 完成

标签: ios swift uilabel


【解决方案1】:

使用:

placeholderLabel.attributedPlaceholder

【讨论】:

    【解决方案2】:

    使用 UITextField 扩展

        extension UITextField {
            func updatePlaceHolder(_ text: String, color: UIColor) {
                attributedPlaceholder = NSAttributedString(string: text,
                                                           attributes: [NSAttributedString.Key.foregroundColor: color])
            }
        }
    //color set for textfield placeholder 
    textFieldNumber.updatePlaceHolder("Mobile Number", color: UIColor.init(red: 0, green: 0, blue: 0.0980392, alpha: 0.22))
    

    【讨论】:

      猜你喜欢
      • 2014-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-20
      • 2012-08-03
      相关资源
      最近更新 更多