Created
January 20, 2019 05:12
-
-
Save shishirthedev/06951ade6cb607f1d5a1a5317f6f294d 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
import UIKit | |
@IBDesignable class CardView: UIView { | |
@IBInspectable var cornerradius:CGFloat = 4 | |
@IBInspectable var shadowOffsetWidth:CGFloat = 0 | |
@IBInspectable var shadowOffsetHeight:CGFloat = 3 | |
@IBInspectable var shadowColor: UIColor = UIColor.gray | |
@IBInspectable var shadowOpacity: CGFloat = 0.3 | |
@IBInspectable var borderWidth: CGFloat = 1 | |
@IBInspectable var borderColor: UIColor = UIColor.clear | |
override func layoutSubviews() { | |
// Corner.............. | |
layer.cornerRadius = cornerradius | |
// Shadow........... | |
layer.shadowColor = shadowColor.cgColor | |
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight) | |
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerradius) | |
layer.shadowPath = shadowPath.cgPath | |
layer.shadowOpacity = Float(shadowOpacity) | |
layer.masksToBounds = false | |
// Border............. | |
layer.borderWidth = borderWidth | |
layer.borderColor = borderColor.cgColor | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment