Last active
December 26, 2015 04:39
-
-
Save stephenparish/7094561 to your computer and use it in GitHub Desktop.
Using auto layout with a child UIViewController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "SPAutoLayoutChildViewController.h" | |
@implementation SPAutoLayoutChildViewController | |
- (void)updateViewConstraints { | |
if (self.view.superview) { | |
UIView *thisView = self.view; | |
thisView.translatesAutoresizingMaskIntoConstraints = NO; | |
NSDictionary *views = NSDictionaryOfVariableBindings(thisView); | |
[self.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[thisView]|" options:0 metrics:nil views:views]]; | |
[self.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[thisView]|" options:0 metrics:nil views:views]]; | |
} | |
[super updateViewConstraints]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment