I am trying to add a drop shadow to a table cell but can't seem to get it to work.
I was able to successfully do it to a UIView in a scrollview using:
myStatsView.layer.shadowColor = UIColor.blackColor().CGColor
myStatsView.layer.shadowOffset = CGSizeMake(0,1)
myStatsView.layer.shadowRadius = 3
myStatsView.layer.shadowOpacity = 0.5
But I have updated my app for Swift 2 and decided to use table view instead of scrollview.
I tried adding the cell content view as an outlet but nothing seems to work.
Is it even possible to add shadows in between table cells? I don't want all cells to have a shadow, just some.
Thanks
I used different technique to add drop shadow to table cell. I add one UIView into the cell and add other controls like UILabel, UIImageView into that view and give the drop shadow to that view. Bellow is the code
self.viewBg!.layer.shadowOffset = CGSizeMake(0, 0)
self.viewBg!.layer.shadowColor = UIColor.blackColor().CGColor
self.viewBg!.layer.shadowRadius = 4
self.viewBg!.layer.shadowOpacity = 0.25
self.viewBg!.layer.masksToBounds = false;
self.viewBg!.clipsToBounds = false;
In above code viewBg is IBOutlet object.
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