Below code explains how you can place a view to the centre of the layout using Autolayout in iOS.


[self.view addConstraint:
 [NSLayoutConstraint constraintWithItem:self.view
                     attribute:NSLayoutAttributeCenterX
                     relatedBy:0
                     toItem:view
                     attribute:NSLayoutAttributeCenterX
                     multiplier:1
                     constant:0]];

[self.view addConstraint:
 [NSLayoutConstraint constraintWithItem:self
                     attribute:NSLayoutAttributeCenterY
                     relatedBy:0
                     toItem:view
                     attribute:NSLayoutAttributeCenterY
                     multiplier:1
                     constant:0]];

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.