Easy way to disable a UITextField?

In Objective-C:

textField.enabled = NO;

In Swift:

textField.isEnabled = false

Reference: UIControl.isEnabled


If you also want to indicate that the text field is disabled you should add more code:

if using UITextBorderStyleRoundedRect, you can only gray out text:

textField.enabled = NO;
textField.textColor = [UIColor lightGrayColor];

if using any other style, you can also gray out background:

textField.enabled = NO;
textField.backgroundColor = [UIColor lightGrayColor];