Last active
June 16, 2017 13:40
-
-
Save sssbohdan/7828372d8b21dc5d829fea249b22aac7 to your computer and use it in GitHub Desktop.
Shadow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addShadow(color: UIColor, fillColor: UIColor, radius: CGFloat = 3, opacity: Float = 0.5, offset: CGSize, cornerRadius: CGFloat = 0) { | |
let shadowLayer = CAShapeLayer() | |
shadowLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath | |
shadowLayer.shadowColor = color.cgColor | |
shadowLayer.shadowPath = shadowLayer.path | |
shadowLayer.shadowOffset = offset | |
shadowLayer.shadowOpacity = opacity | |
shadowLayer.shadowRadius = radius | |
shadowLayer.masksToBounds = false | |
shadowLayer.fillColor = fillColor.cgColor | |
layer.insertSublayer(shadowLayer, at: 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment