Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HStack Fill equally #6

Open
OuSS-90 opened this issue Feb 20, 2018 · 1 comment
Open

HStack Fill equally #6

OuSS-90 opened this issue Feb 20, 2018 · 1 comment

Comments

@OuSS-90
Copy link

OuSS-90 commented Feb 20, 2018

Hello,
I have two label inside HStack and i want to make them fill equally (each label = 50% width of content)
How can i do that ? I tried align(.fill) but didn't work

@nerdycat
Copy link
Owner

nerdycat commented Feb 26, 2018

By default HStack(or VStack) only supports items with intrinsic content size or fixed size. With one exception, align(.fill), which will stretch the cross axis to match the size of Stack (aka. vertical axis for HStack, horizontal axis for VStack).

If you want a proportional size for your items on main axis, you have to combine with constraints.
view1.makeCons { $0.width.equal(view2).multiply(0.3) }

In your case, simply use:
label1.makeCons { $0.width.equal(label2) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants