Author Topic: How do I disable a UIButton so it appears dimmed?  (Read 2214 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How do I disable a UIButton so it appears dimmed?
« on: June 18, 2014, 05:56:54 PM »
if you have a UIButton that is using simple text as the button title, it's not enough to set the enabled property of the button to NO in order for the button to appear disabled. You also need to set it's alpha property. For example:

Code: [Select]
nextButton.enabled = NO;
nextButton.alpha = .5;

and here is how you re-enable the button:

Code: [Select]
nextButton.enabled = YES;
nextButton.alpha = 1;

All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: July 20, 2015, 04:19:27 AM by kjmcneish »