Created
October 12, 2017 08:48
-
-
Save NikhilManapure/56619d762a061fdd5e357cf1e82a0149 to your computer and use it in GitHub Desktop.
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
class CornerRadiusWithShadowView: UIView { | |
var cornerRadius: CGFloat = 2.0 | |
var shadowOffsetWidth: Double = 0.0 | |
var shadowOffsetHeight: Double = 3.0 | |
var shadowColor: UIColor = .black | |
var shadowOpacity: Float = 0.5 | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
layer.cornerRadius = cornerRadius | |
layer.masksToBounds = false | |
layer.shadowColor = shadowColor.cgColor | |
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight) | |
layer.shadowOpacity = shadowOpacity | |
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius) | |
layer.shadowPath = shadowPath.cgPath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment