UIButton: currentBackgroundImage property
The currentBackgroundImage property is the background image the button is displaying right now: the one selected by the current state.
Value
UIImage, or null.
- Read-only. Assigning to it throws
TypeError. - When the current state hasn't been set separately, it reads the one for the
normalstate. - There is no change notification. It changes with the button's state: when a finger touches down and lifts (the system fires control events such as
touchdownandtouchupinside), or when code changesisEnabledorisSelected. The state itself has no change event, so read it again at those moments. nullwhen no state has a background image set. Not verified in the simulator.
Examples
js
const button = new UIButton();
console.log(button.currentBackgroundImage);Result: Prints null. Not verified in the simulator.
Corresponding iOS API
UIButton.currentBackgroundImage.
See also
- States: when the button is in which state