Skip to content

Instantly share code, notes, and snippets.

@gazolla
Created June 20, 2016 01:00
Show Gist options
  • Save gazolla/19c7771b33fa5f781bc7f5b0aa842dbd to your computer and use it in GitHub Desktop.
Save gazolla/19c7771b33fa5f781bc7f5b0aa842dbd to your computer and use it in GitHub Desktop.
Programmatically create UIStackView
lazy var v1:UIView = {
let v = UIView()
v.backgroundColor = .blueColor()
return v
}()
lazy var v2:UIView = {
let v = UIView()
v.backgroundColor = .blueColor()
return v
}()
lazy var stack:UIStackView = {
let s = UIStackView(frame: self.view.bounds)
s.axis = .Vertical
s.distribution = .FillEqually
s.alignment = .Fill
s.spacing = 5
s.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
s.addArrangedSubview(self.v1)
s.addArrangedSubview(self.v2)
return s
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment