how to change placeholder color in swift ios

Copy and paste this extension on you project an access this 

extension UITextField
{
    func setPlaceholder(_ color:UIColor)
    {
        self.attributedPlaceholder = NSAttributedString(string: self.placeholder ?? "", attributes: [NSAttributedString.Key.foregroundColor: color])
    }
}

Used this like

txtYouTextFiledName.setPlaceholder(UIColor.red)

Comments

  1. This is very help full of iOS 13 crash
    Thank Harsh

    ReplyDelete
  2. Thank harsh Gohil for this important things
    my all apps are crash because of this

    Thanks agent

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Keys

Important extensions while create a new App in swift

S.O.L.I.D. Principles with Example (Swift & Dart)