Last active
October 5, 2018 05:59
-
-
Save fmaxx/d800f6060e04f8745b451ffbb8c65b89 to your computer and use it in GitHub Desktop.
UIView, shadow
This file contains 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
// dropsahdow | |
extension UIView{ | |
func dropShadow(shadowColor: UIColor = UIColor.black, | |
fillColor: UIColor = UIColor.white, | |
opacity: Float = 0.2, | |
offset: CGSize = CGSize(width: 0.0, height: 1.0), | |
radius: CGFloat = 10) -> CAShapeLayer { | |
let shadowLayer = CAShapeLayer() | |
shadowLayer.path = UIBezierPath(roundedRect: self.bounds, cornerRadius: radius).cgPath | |
shadowLayer.fillColor = fillColor.cgColor | |
shadowLayer.shadowColor = shadowColor.cgColor | |
shadowLayer.shadowPath = shadowLayer.path | |
shadowLayer.shadowOffset = offset | |
shadowLayer.shadowOpacity = opacity | |
shadowLayer.shadowRadius = radius | |
layer.insertSublayer(shadowLayer, at: 0) | |
return shadowLayer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment