Is there a way to combine below 3 syntax lines into a single one statement like (which doesn’t work):
[_cardsContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[cardContainer1]|[cardContainer2]|[cardContainer3]|" options:0 metrics:nil views:viewsDictionary]];
1. [_cardsContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[cardContainer1]|" options:0 metrics:nil views:viewsDictionary]];
2. [_cardsContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[cardContainer2]|" options:0 metrics:nil views:viewsDictionary]];
3. [_cardsContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[cardContainer3]|" options:0 metrics:nil views:viewsDictionary]];
No, but you can do it in two lines:
This pins card container 1 to the top and bottom of the superview. Then:
Which aligns the top and bottom of the remaining card containers.
This assumes you want the views laid out next to each other, you didn’t actually specify any horizontal layout details.
It helps when using the visual format to think about each line of visual format language representing a single row or column of layout in your view.