Pregunta

I'm trying to create a simple effect where a cell casts a shadow on top of the cell directly below (in a vertical UITableView). Much like a tiled roof where the top tile is layered above the tile below and casts a shadow on the cell below.

I've tried overriding layoutSubviews in UITableView and played with bringSubviewToFront etc but that did not work. The shadow works somewhat but disappears as you tap on a cell (somehow the selected view overlaps it).

Any way to do this easily?

¿Fue útil?

Solución

It seems the only reliable way is to draw the 'shadow' on the cell below the top one and then keep track of global selection states. A second option is to use UICollectionView instead but that's an overkill.

Otros consejos

For cell dropping shadow on the one below:

  • Add shadow to the layer of a view in your cell.

For all cells dropping shadows only on the background view

  • Add shadow to the layer of the tableview itself.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top