Disable blinking cursor from UITextField in swift?

For Swift 4 that works for me:

textField.tintColor = UIColor.clear

initially set the some bool value in user default, when user press the logout button set the value as NO

for e.g

UserDefaults.standard().set(true, forKey: "disalert")

when ever you comes to this page check the condition like as

let disalert: Bool = UserDefaults.standard().bool(forKey: "disalert")

      self.youtextField().tintColor = UIColor.blueColor()
    if disalert {
        self.youtextField().tintColor = UIColor.clearColor()
        self.youtextField().resignFirstresponder()
     }

when ever user press the login button set the user default value as

UserDefaults.standard().set(false, forKey: "disalert")

use like

(self.youtextField.valueForKey("textInputTraits") as! String)["insertionPointColor"] = UIColor.clearColor()

or set like

 self.youtextField().tintColor = UIColor.clearColor()

if you just don't want cursor then you can set it's tintColor to clearColor. In this case your textField will be active. If you want to make it inactive field then you should call resignFirstresponder method of textfield!