Praveen Kumar
Praveen Kumar

Reputation: 1340

Auto Layout implementation in iOS using VFL

I am using the auto layout using the visual formatting language.

In horizontal mode, I can include both labels in a single line of code like this

 constraints  = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-20-[Btn1]-10-[dummyLabel1]-10-[Lbl2]-10-[dummyLabel2]-10-[Btn2]" options:0 metrics:metrics views:views];
[self.view addConstraints:constraints];

I had to use to two lines of constraints like this to place two objects in vertical mode.

 constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[dummyLabel]-16-[fixedLabel]-13-|" options:0 metrics:metrics views:views];
[self.view addConstraints:constraints];

constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[dummyLabel2]-16-[fixedLabel]-13-|" options:0 metrics:metrics views:views];
[self.view addConstraints:constraints];

Is there any way i can do this in a single line for the vertical mode as well using VFL?

Upvotes: 0

Views: 169

Answers (1)

bpapa
bpapa

Reputation: 21497

No. There's a lot of different ways to do Auto Layout: in Interface Builder, using the VFL, creating NSLayoutConstraints programmatically, or using Layout Anchors. Each has their own shortcomings. This is one of the places the VFL breaks down.

Upvotes: 2

Related Questions