UIButton: currentTitleColor property
The currentTitleColor property is the title color the button is displaying right now: the one selected by the current state.
Value
A color string.
- 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. - Always has a value; never
null.
Examples
js
const button = UIButton.buttonWithType('system');
button.setTitleColor('#FF3B30', { forState: ['normal'] });
console.log(button.currentTitleColor);Result: Prints #FF3B30. The color string you wrote reads back as is.
Corresponding iOS API
UIButton.currentTitleColor.
See also
- States: when the button is in which state