Cupcake
Cupcake copied to clipboard
HStack Fill equally
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
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) }