Reputation: 1218
I'm new to autolayout and I was doing fine until I wanted proportional constraints. If someone can explain me how to recreate this behavior using autolayout (on the IB) I think I would fully understand. I know how to set the y constraint, what I don't know is how to set the x constraint to be proportional to the size of the super view so the x position is updated after rotation or whatever. I heard of using dummy views and doing something programmatically but I want a straight forward solution on the IB if possible.
Upvotes: 1
Views: 1244
Reputation: 11
Please don't add a empty view. Just Align Center to Y, and adjust the ratio. For example: 3:2 would be 75% margin.
Upvotes: 1
Reputation: 77641
You say you are looking for a straight forward method for doing this. But you have already disregarded the most straight forward method.
Add a view at the top of your superview and make its height proportional to the height of the superview.
Now add your view so that it sits directly next to this previous view.
Make the "spacer" view hidden.
Done. No code necessary.
Upvotes: 1