I've a horizontal stackview which has a stackview as a subview with 2 labels. Alignment & Distribution are set to Fill in Xcode Attribute Inspector. I want to display 7 subview stacks inside the stack view with 4 in first row and 3 in second row using only one horizontal stackview. I have loaded first row. When I add 5th element, it is appearing in 1st row instead of 2nd row. Number of subviews changes dynamically. If there are 3 elements it should only display only one row. If more than 5, it should display in 2 rows.Below is the code.
if let viewInfos = TestViewController.viewInfos{
let dataNib = UINib(nibName: "InfoStackView", bundle: frameworkBundle)
for viewInfo in viewInfos {
let infoStackView = dataNib.instantiateWithOwner(nil, options: nil)[0] as! InfoStackView
infoStackView.addInfoToStackView(viewInfo: viewInfo)
self.InfoStackView.addArrangedSubview(infoStackView)
}
}
Inside addInfoToStackView method, i add the label for each stackview
Above code adds stackview as subviews horizontally. I want to restrict 4 in first row and 3 in next row. Please help me how do this.