Petravd1994
Petravd1994

Reputation: 903

Stack view is too big for the objects inside

Well I just started working with Stack views. Lets say I have 3 UILabels that I want to fill all over the width of the superview, horizontally placed. I now see that the last UILabel isn't placed really to the edge of the screen, but the first UILabel is placed correctly. When I click on the Stack View I see that the Stack View is placed correctly, but when I click on the last UILabel it isn't really on the edge of the Stack View. So my question is what am I doing wrong? I tried all different options like fill equally etc. The result of this is that there is a tiny space left on the edge of the screen on iPhone SE and a bigger space of the screen on the iPhone 7. I am not using constrains to margins. I can update this question with pictures if you can not understand what I am meaning.

Picture of which shows that the size of the stack view is stretching to the edges. However, I am also getting the error the the labels inside are missing the X position or width, why is this needed? https://postimg.org/image/49hl5gmuh/

This picture shows that the score of player 4 (the last object in the stack view) doesn't reach the edge of the stack view https://postimg.org/image/hxj0xvfn5/

Upvotes: 0

Views: 1694

Answers (1)

matt
matt

Reputation: 534885

It works if your settings for the stack view are correct (the dark lines at the outside are the shadow of the simulator, so you can see the right and left labels are right against the edge):

enter image description here

I used Equal Spacing, and the stack view itself has constraints pinning its edges to the edges (not the margins!) of the superview.

Upvotes: 1

Related Questions