IPhone : IOS autolayout with VFL , regarding NSLayoutFormatAlignAllCenterY

on Friday, March 27, 2015

I was trying to use VFL with autolayout, But I got a bit confused with NSLayoutFormatAlignAllCenterY and >= , for example


I have one view v, which contains two button, b1 , b2, below is the code and final result (sorry for not having enough reputation to post image):



v
----------------------
|
|
b1 b2 |
----------------------

NSDictionary *metrics = @{@"hPadding":@5,@"vPadding":@5};


NSDictionary *dict1 = NSDictionaryOfVariableBindings(v,b1,b2);


NSString *vfl = @"|-hPadding-[v]-hPadding-|";


[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl options:0 metrics:metrics views:dict1]];


NSString *vfl2 = @"V:|-45-[v]"; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl2 options:0 metrics:metrics views:dict1]];



NSString *vfl3 = @"V:|-vPadding-[b1]-vPadding-|";


[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl3 options:NSLayoutFormatAlignAllLeft metrics:metrics views:dict1]];


NSString *vfl3 = @"|-hPadding-[b1]-(>=50)-[b2]-hPadding-|";



[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl3 options:NSLayoutFormatAlignAllCenterY metrics:metricsviews:dict1]];




My question is, why it has to use ">=50 and options:NSLayoutFormatAlignAllCenterY" to make the layout like the pic above???


what is the difference between "options:NSLayoutFormatAlignAllCenterX" options:NSLayoutFormatAlignAllCenterY


Does anyone knows? thank you in advanced.......


0 comments:

Post a Comment