Last active
November 15, 2018 20:40
-
-
Save srdanrasic/a048e39cb7a392d8067b363be710f3f6 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
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