Skip to content

Instantly share code, notes, and snippets.

@srdanrasic
Last active November 15, 2018 20:40
Show Gist options
  • Save srdanrasic/a048e39cb7a392d8067b363be710f3f6 to your computer and use it in GitHub Desktop.
Save srdanrasic/a048e39cb7a392d8067b363be710f3f6 to your computer and use it in GitHub Desktop.
extension UIView {
public convenience init<V>(style: Style<V>) {
self.init(frame: .zero)
apply(style)
}
public func apply<V>(_ style: Style<V>) {
guard let view = self as? V else {
print("💥 Could not apply style for \(V.self) to \(type(of: self))")
return
}
style.apply(to: view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment