Created
August 8, 2019 06:15
-
-
Save GoranLilja/e924955c5c4b1b16105e103824cb4eb7 to your computer and use it in GitHub Desktop.
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 | |
func create<T>(_ input: T? = nil, _ setup: ((T) -> Void)) -> T where T: NSObject { | |
let obj = input ?? T() | |
setup(obj) | |
return obj | |
} | |
func create<T>(_ input: T? = nil, _ setup: ((T) -> Void)) -> T where T: UIView { | |
let obj = input ?? T() | |
obj.translatesAutoresizingMaskIntoConstraints = false | |
setup(obj) | |
return obj | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment