Search code examples
iosxcodeuitableviewuiimageviewuicolor

Change image in UIImageView when row is selected?


This is how item looks when it is selected.

enter image description here

Normally row has black background, and icon has white foreground. But selecting a row will made background semi white. Is it a way to change image to opposite color, or use a different image in imageView when imageView's row is selected?


Solution

  • Using @NSDmitry's example, you need to override setSelected(_ selected: Bool, animated: Bool) on the UITableViewCell and set the tintColor of the whole contentView or just the imageView