Re: UIStackView full of labels doesn't add up
Re: UIStackView full of labels doesn't add up
- Subject: Re: UIStackView full of labels doesn't add up
- From: Ken Thomases <email@hidden>
- Date: Sun, 20 Mar 2016 09:52:41 -0500
On Mar 20, 2016, at 7:57 AM, Roland King <email@hidden> wrote:
>
> I have a UIStackView, vertical, set to ‘fill equally’ with a number of UILabels in it. The stackview in this instance happens to be 300pts high. If I put 1 UILabel in it, the UILabel is 300pts high. This is what I would expect.
>
> If I put two in it, the stackview sets them both 160pts high (total 320), three, they’re 113pts high (total 330) , four, 90pts high (total 360). None of those add up to 300 so the labels are not properly spaced out and don’t line up correctly with other groups of views which are next to them.
What are you using to measure the label heights? Are you looking at the frame or the alignment rect (i.e. applying -alignmentRectForFrame: to the frame)? Anything using auto layout, such as UIStackView, will use the alignment rect. The alignment rect may very well be inset from the frame so that if you (or UIStackView) makes two labels abut according to their alignment rects, their frames may actually overlap.
Also, have you set the stack view's baselineRelativeArrangement or spacing properties?
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden