iOS UIButton - Difference between UIButton setUserInteractionEnabled and setEnabled

They are nearly the same. userInteractionEnabled is a property of UIView that toggles whether the view receives any user touches. enabled is a property of UIControl (which is a subclass of UIView and a superclass of UIButton) and has the same effect. One difference is that UIKit controls may draw themselves differently depending on their enabled state, which isn't the case for the abstract UIView.

Okay, then why?

Since UIControl subclasses inherit both, why are there two almost-the-same properties? Why don't controls just drop the idea of "enabled" and draw themselves differently based on their userInteractionEnabled state?

At least one reason is that during animation, user interaction is disabled on UIViews. It would be wrong for controls to draw themselves as greyed out while they are animated. So at least during animation, the two properties have distinct meanings.


Characteristics of enabled:

  • It's a property of UIControl
  • Superclass for UIButton.
  • It has effects on the visual state of the object and is generally the preferred method of disabling a control

Characteristics of userInteractionEnabled:

  • A property of UIView
  • Code that interacts with your controls is more likely to check if buttons are enabled than if their userInteractionEnabled property is set. It's more conventional.