Skip to content

Instantly share code, notes, and snippets.

@digoreis
Created May 7, 2019 13:23
Show Gist options
  • Save digoreis/faf8aa0f549f95fcf7662fd49ebb8f95 to your computer and use it in GitHub Desktop.
Save digoreis/faf8aa0f549f95fcf7662fd49ebb8f95 to your computer and use it in GitHub Desktop.
Create a UIView
func create<T: UIView>(usingAutoLayout: Bool = true, configure: (T) -> Void) -> T {
let object = T()
object.translatesAutoresizingMaskIntoConstraints = !usingAutoLayout
configure(object)
return object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment