How to grey out a button to let the user know that it is currently disabled in iOS?
Use following code for customizing button's title for disabled state. You can call it inside viewDidLoad
:
button.setTitleColor(UIColor.grayColor(), forState: .Disabled)
If you would like to customize a background colour for the disabled button, use approach from this answer: How to change background color of UIButton when it's highlighted
Swift 5.3:
button.setTitleColor(.systemGray, for: .disabled)
You can do this via Storyboard. Select the button, go to identity inspector and click on state configuration and choose "disable" state. Then set the background color of the button to gray color. From here you can customize your UIButton according to your requirements in different states and all you need is to manage setting the state of the button in your code.
Swift 3
As accepted answer, but updated for Swift3
button.setTitleColor(UIColor.gray, for: .disabled)