UIImageView: isHighlighted property
The isHighlighted property determines whether the image view is in the highlighted state, that is, whether it shows image or highlightedImage.
Value
A boolean.
- Readable and writable.
- The default value is
false. true: showshighlightedImage.false: showsimage.- The system doesn't change it automatically.
UIImageViewdoesn't receive touches by default, so it doesn't becometruewhen a finger presses on it. If you need the image to switch automatically while a finger is pressed, useUIButton'ssetImage()to set a separate image for thehighlightedstate.
Examples
js
const iv = new UIImageView();
iv.image = UIImage.systemImageNamed('star');
iv.highlightedImage = UIImage.systemImageNamed('star.fill');
iv.isHighlighted = true;
iv.isHighlighted = false;Effect: setting it to true shows a filled star; setting it back to false switches back to an outlined star. The image switching is not verified in the simulator.
Corresponding iOS API
UIImageView.highlighted (the getter is isHighlighted).