I'm trying to implement this design but all solutions I have browsed won't work and from what I understand it could be because of the spacing between the cells and the UITableView.
Here's the design:

So basically what I'm trying to achieve is to have shadows from all 4 sides as well as some spacing between each cell and the following cell. Thanks
Edit: Here's the code I tried.
let shadowSize : CGFloat = 5.0
let shadowPath = UIBezierPath(rect: CGRect(x: -shadowSize / 2,
y: -shadowSize / 2,
width: self.avatarImageView.frame.size.width + shadowSize,
height: self.avatarImageView.frame.size.height + shadowSize))
self.avatarImageView.layer.masksToBounds = false
self.avatarImageView.layer.shadowColor = UIColor.black.cgColor
self.avatarImageView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
self.avatarImageView.layer.shadowOpacity = 0.5
self.avatarImageView.layer.shadowPath = shadowPath.cgPath
Edit 2: I'd like to point out that all my cell's objects are inside a container UIView. All the above code is applied to this UIView.
You have to make a UIView inside UITableViewCell and work on that view.
FOR SHADOW I AM USING THIS IN UITableViewCell CLASS:-
viewDummy.addShadow() //use from any view
extension UIView {
func addShadow(){
self.layer.shadowColor = UIColor.blackColor().CGColor
self.layer.shadowOpacity = 0.5
self.layer.shadowRadius = 2.0
self.layer.shadowOffset = CGSizeMake(1.0, 1.0)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With