Reputation: 2389
I am trying place two identically sized sets of a UILabel directly above a UITextField on a UIView. I figured that this would be an excellent use of stack views.
Here is a screenshot of my elements
However, for some reason, Xcode seems to expect that the UILabel will be much taller than it should be and results in warnings about the layout.
With the UILabel selected, you can see the outline. You can also see this same sized outline on the other UILabel too, and when selecting the stack view elements it also shows the larger area. When clicking on the UITextField, the outline is shown to begin where the outline from the UILabel ends. Using the 'Resolve Auto Layout Issues' to 'Update Frames' will make the stack view expand outwards to match the size of the outline, however it instantly jumps back to the original size.
Am I misusing or have I misconfigured the stack views? Or is there some other issue going on?
I am using Xcode 7.3 build 7D111g.
Upvotes: 3
Views: 4782
Reputation: 5130
This is because your label
is filling the stackview
.
Don't give height constraint to stackview
. Just add the following two constraints to top stackview
Stackview
will get its height from its content.
Check this updated GIF :
All warning get finished.
Hope this can help.
Upvotes: 2