Ios – Easy way to disable a UITextField


Is there an easy way to disable a UITextField in code?

My app has 12 UITextField that are all turned on by default, but when a change is detected in my Segment Control I want to disable some of the UITextField depending on what Segment the user picks.

Just need to know how to disable it or make it non-editable?


Best Solution

In Objective-C:

textField.enabled = NO;

In Swift:

textField.isEnabled = false

Reference: UIControl.isEnabled