Olimjon Kenjaev
Olimjon Kenjaev

Reputation: 39

UITableViewCell shadow

How to add a shadow to both sides, top and bottom, of UITableViewCell?

I have tried this:

cell.layer.shadowOpacity = 0.75f;
cell.layer.shadowRadius = 5.0;
cell.layer.shadowOffset = CGSizeMake(0, 0);
cell.layer.shadowColor = [UIColor blackColor].CGColor;

However, it only displays a shadow to the bottom of the cell.

Upvotes: 0

Views: 3108

Answers (1)

Olimjon Kenjaev
Olimjon Kenjaev

Reputation: 39

The problem was in z position of UITableViewCell. Actually, it was displaying the top shadow too, but the upper cell had bigger z position so that top shadow was under it.

I have just changed the z position of cell layer like this:

selectedCell.layer.zPosition = 999;

Upvotes: 2

Related Questions