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

how to send invite and give a access of selected application on App Store

how to display popover in TableView cell in swift