Created
January 5, 2018 09:10
-
-
Save pofat/4fbe782c4ff9b0eaa57d6c2f11f128ed to your computer and use it in GitHub Desktop.
Better way of adding subviews at once.
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
/* | |
From: https://twitter.com/johnsundell/status/948513364015288320?utm_content=buffer67c28&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer | |
*/ | |
extension UIView { | |
func add(_ subviews: UIView...) { | |
subviews.forEach(addSubview) | |
} | |
} | |
/* | |
//So that you can do | |
view.add(label, button) | |
// instead of | |
view.add(label) | |
view.add(button) | |
// Which works well sementically | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment