Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell Layer Shadow Overlap Cell above

Everything is in the Title.

I have a UITableView with cells. The cells has a Shadow (self.layer.shadow...).

The problem is that the shadow of one cell is Overlapping the cell above. How can I prevent this behavior ?

enter image description here

And here is the code in my cell :

    self.layer.shadowColor = UIColor.gray.cgColor
    self.layer.shadowOffset = .zero
    self.layer.shadowOpacity = 0.15
    self.layer.shadowRadius = 10
    self.layer.cornerRadius = 8
    backgroundColor = .white
like image 211
Alexis Darnat Avatar asked Nov 08 '22 07:11

Alexis Darnat


1 Answers

Use this code for adding shadow :-

self.layer.masksToBounds = false
self.layer.shadowOffset = CGSize(width: -1, height: 1)
self.layer.shadowOpacity = 0.2
self.layer.cornerRadius = 8
like image 114
Aditya Srivastava Avatar answered Nov 15 '22 13:11

Aditya Srivastava