I am using a UIStackView in iOS 9 SDK. The height of the stackview is 44 points. I have a UILabel and UIView inside the StackView as shown below:
Now, I wa
I wanted to post my answer here so others could see, despite a slightly different problem from OP's.
I was trying to resize a UIView that contained a UIStackView and the constraints were breaking. I was changing the UIView's height constraint between 0 and 66 depending on if there was relevant info to show that the stack view was displaying for.
I was able to fix the breaking constraints by removing top and bottom constraints of the stack view inside the view, and instead set it to be vertically centered. This resulted in much smoother scrolling in my table view.
Then all you have to do is add another UIView to your green view. Make that UIView's size 20x20pts. Then change the small view background to green and the larger view's background to clear.
That said, this solution doesn't require a stackview and possibly over-complicates your UI. I would recommend just using autolayout instead.
That list isn't exhaustive, but should give you an idea of when and why you'd use a stack view.
This behavior is trivial. You can simply set the constraints on your view: '
And then set the constraints on the stackview:
Hope this helps, cheers!
The breaking constraint problem can be easily fixed by setting the priority of width and height constraints to 800 or above.
First you need to add UIStackView
on the cell
Need to add constraints to your UIStackView
Adjust your UIStackView
Drag&Drop UILabel
into your UIStackView
Then Drag&Drop UIView
into your UIStackView
Add green-UIView
like subview to pink UIView
Now you can add couple constraints to green-UIView
Now you can run app on simulator or device
Notice that I don't added any constraints for UILabel
.