Skip to content

Instantly share code, notes, and snippets.

@nathanborror
Created March 4, 2014 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanborror/9338630 to your computer and use it in GitHub Desktop.
Save nathanborror/9338630 to your computer and use it in GitHub Desktop.
constraintsWithVisualFormats
// 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