Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode AutoLayout, Make Margin proportional with height

I am having a big time figuring out how to make the margin of two objects proportional. If i choose aspect ratio on Xcode it gives me the option for adjust the height of my object proportional screen height. and thats not my case. I want the margin between a button and screen bottom to be proportional to screen height. And i want it to be done using Xcode "No Code".What I am seeking to do

Your support is highly appreciated.

Thank you

like image 297
Mostafa Mohamed Raafat Avatar asked Jun 26 '15 13:06

Mostafa Mohamed Raafat


2 Answers

Use the multiplier property of NSLayoutConstraint !

First, set the equal height constraint from your view to its superview with the multiplier you wish. You can use Ctrl + drag from your view to the superview.

Then set another constraint at 0 from the top of your view to the superview and a equal width constrain with a multiplier to 1 from your view to the superview.

Done !

like image 145
GaétanZ Avatar answered Sep 21 '22 11:09

GaétanZ


Add transparent view and make it proportional to height. Bind you Done button with this transparent view. There you can find how to make it.

like image 42
ChikabuZ Avatar answered Sep 19 '22 11:09

ChikabuZ