Created
May 21, 2020 07:39
-
-
Save deya-eldeen/f64cc158b52409409379e07740fceba7 to your computer and use it in GitHub Desktop.
CardView
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
import UIKit | |
@IBDesignable class CardView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
setup() | |
} | |
func setup(){ | |
backgroundColor = .white | |
addShadow() | |
layer.cornerRadius = 6 | |
//layer.masksToBounds = true | |
} | |
} | |
extension UIView { | |
func addShadow(opacity: Float = 0.4, color: UIColor = UIColor.gray, radius: CGFloat = 4, offset: CGSize = CGSize(width: 2, height: 2)){ | |
layer.shadowOffset = offset | |
layer.shadowOpacity = opacity | |
layer.shadowColor = color.cgColor | |
layer.shadowRadius = radius | |
layer.masksToBounds = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment