Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show cell shadows that spills over to another cell in Swift

I'm trying to implement the following card style in my app, and I'm having an issue with the shadow element for each card.

Invision UI Kit

Issue

The shadow of a cell is not displayed behind the cell directly below it.

UITableView is used, and cell background is set to transparent.

enter image description here

Question #

  • Is it possible to allow the shadow to 'spill over' to the cell area below it?

I suspect the shadow cut-off is caused by the cell's height. I don't want to increase the space between each 'card', so increasing the cell's height is not a good option.

like image 848
J100 Avatar asked Oct 21 '17 01:10

J100


2 Answers

So you might possibly be able to solve it by setting each cell's clipsToBounds to false and/or their layer's masksToBounds to false. I doubt it'll work, but is worth a try.

What I suspect you'll need to do is specify the cells as transparent, then place a view within them that is not as high as the cell, to leave room for that view's shadow. So the view looks like a card with shadow, and is offset within the transparent cell so that the card + shadow fits perfectly within the cell.

like image 191
Smartcat Avatar answered Oct 21 '22 02:10

Smartcat


Try to set the cell's backgroundColor to clearColor.

like image 33
liu shuai Avatar answered Oct 21 '22 03:10

liu shuai