2

Inside my table view for each cell I have an image along with some text and other stuff. When I select a cell I want the image also to be covered with blue overlay. Right now all other stuff excluding image is getting selected and a blue overlay covers the cell.

How to achieve this?

Abhinav
  • 37,684
  • 43
  • 191
  • 309

2 Answers2

0

You won't be able to have that blue overlay to cover your image. The blue gradient is the backgroundView of the cell, whereas your UIImage is either drawn inside the contentView or added to it as a subview.

A possible workaround would be to add a CALayer on top of the whole cell that would mimic the default blue background.

samvermette
  • 40,269
  • 27
  • 112
  • 144
0

It seems like there should be a way to do this without modifying your image, but all I can find so far is to specify a new image when the cell is selected. UIImageView has a property for both image and highlightedImage, so it would seem you need to provide your own image to use when the cell is selected, so you would need to set cell.imageView.image and cell.imageView.highlightedImage.

Sam's workaround would be a good approach, also. Especially if you don't want to provide your own image

justin
  • 5,811
  • 3
  • 29
  • 32