I have a subview:
Here is the sub class of that view:
class MyView: UIView {
public init(){
super.init(frame: .zero)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
On my main view controller I have a stackView:
if I add a single view to the stack view:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
generaRedView()
}
func generaRedView() {
let newView = MyView()
newView.backgroundColor = .red
stackView.addArrangedSubview(newView)
}
it looks just fine:
But I add two views to the stack view:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
generaRedView()
generaBlueView()
}
func generaRedView() {
let newView = MyView()
newView.backgroundColor = .red
stackView.addArrangedSubview(newView)
}
func generaBlueView() {
let newView = MyView()
newView.backgroundColor = .blue
stackView.addArrangedSubview(newView)
}
The subviews are been compress:
My question to you guys is how can make the stackView respect the size of the subviews and increase the high of the stack view so the subviews can look normal and not compress?
I'll really appreciate your help.