布局类别

 

#define VFL(ARRAY,VIEWS) ([NSLayoutConstraint constraintsWithVisualFormatsArray:(ARRAY) views:(VIEWS)])

 

@interface NSLayoutConstraint (NSArray)

+ (NSArray *)constraintsWithVisualFormat:(NSString *)format views:(NSDictionary*)dicViews;

+ (NSArray *)constraintsWithVisualFormatsArray:(NSArray *)aryFormats views:(NSDictionary*)dicViews;

@end

 

#import "NSLayoutConstraint+NSArray.h"

 

@implementation NSLayoutConstraint (NSArray)

+ (NSArray *)constraintsWithVisualFormat:(NSString *)format views:(NSDictionary*)dicViews

{

    return [self constraintsWithVisualFormat:format options:0 metrics:nil views:dicViews];

}

 

+(NSArray*)constraintsWithVisualFormatsArray:(NSArray *)aryFormats views:(NSDictionary *)dicViews

{

    NSMutableArray* ary=[[NSMutableArray alloc] init];

    for (NSString* strVFL in aryFormats) {

        [ary addObjectsFromArray:[self constraintsWithVisualFormat:strVFL views:dicViews]];

    }

    return ary;

}

 

@end

 

posted @ 2016-04-28 14:29  mengxiangtong22  阅读(199)  评论(0编辑  收藏  举报