Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top