I want my UIView to take half o the screen size, so the constraints should be: 0 for top, leading and bottom. But what about trailing edge ? I do not want to set a constant value to it.
How can I tell IB that the trailing edge should adjust automatically so that the view is half of the screen on all devices ?
You can also create multiple constraints at once, or you can update the frames as you add the constraints. After you've set the options you want, click the Add Constraints button to create your constraints.
To create constraints select the button and click the Align icon in the auto layout menu. A popover menu will appear, check both “Horizontal in container” and “Vertically in container” options to center the button on the screen. Then click the “Add 2 Constraints” button. Run the application.
Auto Layout constraints allow us to create views that dynamically adjust to different size classes and positions. The constraints will make sure that your views adjust to any size changes without having to manually update frames or positions.
I fixed my problem by ctrl dragging from my view to its superview and choose Equal Widths
and then selected the new constraint and in the Size Inspector
under Multiplier
I changed from 1 to 1:2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With