Reputation: 1401
I am currently having difficulty with AutoLayout. I am using interface builder and am trying to position two buttons of equal width side by side as illustrated in the following image.
From the following Preview image, my titleImage has been properly constrained and is displaying correctly however the buttons are not. I have experimented by aligning button 1 with the leading edge of titleImage, and button2 with the trailing edge of titleImage, however the width distribution between the two buttons becomes skewed at this point, as demonstrated below.
My objective is to understand what constraints are missing and should be applied to the two buttons to maintain equal widths regardless of device. If possible I would like to achieve this through interface builder as opposed to additional code.
Upvotes: 99
Views: 60573
Reputation: 4043
Follow Steps and Screenshots for easy solution
OUTPUT
Hope it Helps you :)
Upvotes: 80
Reputation: 14294
My solution is to
Note: See the Screenshot.
Upvotes: 0
Reputation: 3862
Stack layout in iOS9, will do the job really nice. Add stack view to your view and configure as follow:
Upvotes: 20
Reputation: 9354
You can check my example - you can easy aim this, by using proportional constraint. Also you can easy aim proportional multiple UIViews. Please look attached example
https://dl.dropboxusercontent.com/u/48223929/TestViewController.xib
Upvotes: 2
Reputation: 4078
Add the following constraints
Upvotes: 251