I am working in a mainStackView (UIStackView) that has 4 horizontal subviews (rows), and it works fine as follows (the mainStackView is managed with AutoLayout constraints):
rowsArray = Array<UIView>()
for _ in 0...3 {
let row = UIView()
row.backgroundColor = UIColor.randomColor() //color for debugging
rowsArray.append(row)
}
mainStackView = UIStackView(arrangedSubviews: rowsArray)
mainStackView.axis = .vertical
mainStackView.alignment = .fill
mainStackView.distribution = .fillEqually
mainStackView.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(mainStackView)
Now, given that each subview (row in this case) will have a number of horizontal subviews in it, I need the arrangedSubviews to be Array, but it fails to display any of the subviews.
rowsArray = Array<UIStackView>()
for _ in 0...3 {
let row = UIStackView()
row.backgroundColor = UIColor.randomColor() //color for debugging
rowsArray.append(row)
}
Any idea why the UIStackView does not behave as the superclass (UIView), or if there is any other consideration for nesting UIStackViews programmatically
Rgds... e