Best Practices For Auto Layout Xamarin.IOS

Let's start by creating a Controller.
 
 
Right Click on the controller.
 
Open with Xcode Interface builder.
 
 
Now we will consider a scenario where we have 2 horizontally aligned buttons at the top and 2 at the bottom.
 
The height of all should be equal and 40.
  
So normally what we do is, we assign a height of 40 to all the buttons. But we can do it in a better way by assigning a height of 40 to one of the buttons and equal height to all other buttons with respect to the first buttons.
 
Let's see how we can do that.
 
Assign a height of 40 to the left top button.
 
 
Select the left top button, hold the control key and select all the other 3 buttons.
 
Select Equal Height and click on add Constraint.
 
In this way whenever we want to change the height of all 4 buttons, we don't have to change the constraint for all; changing constraint for top left will reflect the change for all  4 buttons as they have relative height.
 
Now consider a scenario where we want leading and trailing of both the left and the right buttons to be the same.
 
 
Select the left top button hold the command key and select the left bottom button.
 
Click leading edges.
 
Now, whenever we want the leading space of both the buttons to be changed we just need to change it for left top button and it will reflect the same for the other button as its leading constraint is set with respect to the top left button.
 
So with this blog, we have gone through some good practices to be followed while designing the Storyboard or XIB's.
 
Happy Coding :)

Next Recommended Reading Xamarin iOS Custom Fonts