Created
June 20, 2016 01:00
-
-
Save gazolla/19c7771b33fa5f781bc7f5b0aa842dbd to your computer and use it in GitHub Desktop.
Programmatically create UIStackView
This file contains 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
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