Disabled Uibutton Not Faded or Grey

Disabled UIButton not faded or grey

You can use following code:

sendButton.enabled = YES;
sendButton.alpha = 1.0;


sendButton.enabled = NO;
sendButton.alpha = 0.5;

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)

UIButton tintColor for disabled and enabled state?

You could override the isEnabled property to achieve that. The tintColor will be automatically changed according to the button's isEnabled status:

class ButtonsPostMenu:UIButton {


override var isEnabled: Bool {
if self.isEnabled {
self.tintColor = UIColor.white
self.tintColor = UIColor.gray



UIButton disabled state not changing immediately

You're on the right track about checking the main queue, but your additional processing has to finish before the UI gets a chance to update.

If your code is friendly to this approach, use two dispatch blocks back to the main queue. The first would be your UI-state settings, the second, your remaining processing. This lets the UI state actually update before your additional processing complete.


- (IBAction) handlePress:(id)sender {
dispatch_async(dispatch_get_main_queue(), ^{
// Do your state update (button disabled, etc)

dispatch_async(dispatch_get_main_queue(), ^{
// Do your further processing - AFTER the ui has been updated

Related Topics

Leave a reply