Proper Way to Set UIButton Background Color for “.disabled” State

Any Issue on UIButton?

Solution

Usage

// set this in viewDidLoadbutton.setBackgroundColor(.blue, for: .normal)button.setBackgroundColor(UIColor.blue.withAlphaComponent(0.3), for: .disabled)// set enable or disable when neededbutton.isEnabled = true// button.isEnabled = false

References

iOS Developer focusing on Swift — “Learn, that’s how we grow our skill”.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store