Kristof Van Landschoot
Kristof Van Landschoot

Reputation: 1455

How to set autolayout constraint using visual language to superview with default constant and non-default priority

In visual format language a string H:|-[view]-| means: have the standard margins to superview.

If I want these standard margins to have a priority less than the default, I would want to write H:|-@750-[view]-@750-| but that does not work, leaving me the only possibility to write an explicit value for the margin (H:|-8@750-[view]-8@750-|), which I do not want to do (as I have to hard code this margin now).

Is there a way to specify standard margins with a different priority than the default?

Upvotes: 0

Views: 94

Answers (1)

t0rst
t0rst

Reputation: 439

(...nope, I don't see any mention of a term representing standard margin in the VFL documentation either.)

What you can do, is generate standard margin constraints, then pick them out from the results of +constraintsWithVisualFormat:options:metrics:views: and then change their priority before activating and adding them, as you cannot change the priority between required and optional once the constraints are active (though you can still change priority between different optional priority values).

Upvotes: 1

Related Questions