Disable blinking cursor from UITextField in swift?

3 Solutions Collect From Internet About “Disable blinking cursor from UITextField in swift?”

First you need to confirm to UITextFieldDelegate and then set you textField like yourTextField.delegate =self

to your code. Call resignFirstResponder to yourTextField.
and you can also use below code (According to your need).

In delegate method textFieldDidEndEditing(textField: UITextField) with checking (if) whether it has some value/text of not.

yourTextField.attributedPlaceholder = NSAttributedString(string: "User Name", attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()]) textUserName.resignFirstResponder()

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()

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!