Change of UITextField placeholder color

后端 未结 13 1556
别跟我提以往
别跟我提以往 2021-01-30 06:09

How to dynamically change placeholder color of the UITextField? This is always the same system color.

No option in xib editor.

13条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 06:52

    Swift 4

    let placeholderColor = UIColor.red
    self.passwordTextField?.attributedPlaceholder = 
    NSAttributedString(string:"placeholderText", attributes: 
    [NSAttributedStringKey.foregroundColor : placeholderColor])
    

提交回复
热议问题