J100
J100

Reputation: 4156

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 #

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.

Upvotes: 7

Views: 3503

Answers (2)

liu shuai
liu shuai

Reputation: 21

Try to set the cell's backgroundColor to clearColor.

Upvotes: 2

Smartcat
Smartcat

Reputation: 2882

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.

Upvotes: 10

Related Questions