Skip to content

Instantly share code, notes, and snippets.

@StanislavK
Created February 27, 2018 21:14
Show Gist options
  • Select an option

  • Save StanislavK/ac05992681af75e35a83bd179af46de9 to your computer and use it in GitHub Desktop.

Select an option

Save StanislavK/ac05992681af75e35a83bd179af46de9 to your computer and use it in GitHub Desktop.
extension UIView {
func add(_ subviews: UIView...) {
subviews.forEach(addSubview)
}
}
view.add(button)
view.add(label)
// By dropping the "Subview" suffix from the method name, both
// single and multiple arguments work really well semantically.
view.add(button, label)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment