Skip to content

Instantly share code, notes, and snippets.

@spentak
Created March 4, 2016 22:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spentak/3ce795de989019b7cae5 to your computer and use it in GitHub Desktop.
Save spentak/3ce795de989019b7cae5 to your computer and use it in GitHub Desktop.
import UIKit
private var materialKey = false
extension UIView {
@IBInspectable var materialDesign: Bool {
get {
return materialKey
}
set {
materialKey = newValue
if materialKey {
self.layer.cornerRadius = 3.0
self.layer.shadowOpacity = 0.8
self.layer.shadowRadius = 3.0
self.layer.shadowOffset = CGSizeMake(0.0, 2.0)
self.layer.shadowColor = UIColor(red: 157.0/255.0, green: 157.0/255.0, blue: 157.0/255.0, alpha: 1.0).CGColor
} else {
self.layer.cornerRadius = 0
self.layer.shadowOpacity = 0
self.layer.shadowRadius = 0
self.layer.shadowColor = nil
}
self.setNeedsLayout()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment