Created
March 4, 2014 01:39
-
-
Save nathanborror/9338630 to your computer and use it in GitHub Desktop.
constraintsWithVisualFormats
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
// NSArray *formats = @[ | |
// @"H:|-[textView]-|", | |
// @"H:|-[moreButton]-|", | |
// @"V:|-[textView]-[moreButton]-|", | |
// ]; | |
// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormats:formats options:0 metrics:nil views:views]]; | |
@implementation NSLayoutConstraint (Common) | |
+ (NSArray *)constraintsWithVisualFormats:(NSArray *)formats options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views | |
{ | |
NSMutableArray *constraints = [NSMutableArray array]; | |
[formats enumerateObjectsUsingBlock:^(NSString *format, NSUInteger idx, BOOL *stop) { | |
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:format options:opts metrics:metrics views:views]]; | |
}]; | |
return constraints; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment