prior swift 3 i was adding shadow in my UIView like this :
//toolbar is an UIToolbar (UIView)
toolbar.layer.masksToBounds = false
toolbar.layer.shadowOffset = CGSize(width: -1, height: 1)
toolbar.layer.shadowRadius = 1
toolbar.layer.shadowOpacity = 0.5
but the above code is not working in swift 3 , instead of shadow my whole View's color is turned to ugly gray
anyone knows how can we add shadow in swift 3 ?
/* Applies shadow over the View */
Although the accepted answer is great and it works as it should, I've modified it to split
offSet: CGSize
tooffsetX: CGFloat
andoffsetY: CGFloat
.Swift 4
This works for me (Swift 3 and 4)
Here's how to add a shadow to a UIView in Swift 4.1: