NSString *format = [NSString stringWithFormat:@"H:|-10-[self]-10-|"];
NSString *formatVertical = [NSString stringWithFormat:@"V:|-40-[self(300)]|"];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:format options:0 metrics:nil views:viewsDictionary]];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:formatVertical options:0 metrics:nil views:viewsDictionary]];
with formatVertical i am able to set height of my view. But i want to make this value as dynamic to be able to show in all different screens as same look.
Is there anything i can achieve this?
Visual Format Language is nice, except there are a number of layout attributes it cannot do - such as height/width percentages and centering.
The answer from "K. Davydenko" will work... sort of. It still sets a fixed height for your subview though. So if you put that in the wrong place (before the superview is laid out, for example), or if the view changes (such as device rotation), you won't get what you're after.
Since it is rather simple to add a
NSLayoutConstraintin addition to your VFL formatting, that's the better option: