Skip to content

Instantly share code, notes, and snippets.

@Gagan5278
Last active January 26, 2021 14:28
Show Gist options
  • Save Gagan5278/2cfef43b2ef5281ff70e333d1f3e8a77 to your computer and use it in GitHub Desktop.
Save Gagan5278/2cfef43b2ef5281ff70e333d1f3e8a77 to your computer and use it in GitHub Desktop.
extension UIView {
func addSubviews(_ views: UIView...) {
views.forEach{addSubview($0)}
}
}
##How to Use:
class YourViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let view1 = UIView()
let view2 = UIView()
let imgView = UIImageView(image: "plane")
let view3 = UIView()
let lable = UILabel()
//Call here
self.view.addSubViews(view1, view2, imgView, view3, lable)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment