Skip to content

Instantly share code, notes, and snippets.

@deya-eldeen
Created May 21, 2020 07:39
Show Gist options
  • Save deya-eldeen/f64cc158b52409409379e07740fceba7 to your computer and use it in GitHub Desktop.
Save deya-eldeen/f64cc158b52409409379e07740fceba7 to your computer and use it in GitHub Desktop.
CardView
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