How to change UITextfield placeholder color and fontsize using swift 2.0?

前端 未结 10 690
小蘑菇
小蘑菇 2020-12-28 16:22

How to change UITextfield placeholder & fontsize in SWIFT 2.0?

10条回答
  •  悲&欢浪女
    2020-12-28 16:44

    For swift 5.0 use NSAttributedString.Key.foregroundColor instead of NSForegroundColorAttributeName

    So, do it like so

    textField.attributedPlaceholder = NSAttributedString(string: "placeholder text", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
    

提交回复
热议问题