Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write content hugging priority of intrinsic size in visual language format?

I'm trying to put two labels side-by-side using Autolayout--the left label is the field name while the right label is the value. I'm writing the constraints in Visual Language Format.

However, I don't want the left label to grow beyond its intrinsic width, and I want the right label to fill the remaining width in the screen. I know that I simply need to assign a higher content hugging priority on the left label's intrinsic width, but how do I write the intrinsic width in VLF?

I'm expecting my VLF string to look something like this:

H:|-20-[leftLabel(==intrinsicContentWidthGoesHere@1000)]-20-[rightLabel]-20-|
like image 988
MLQ Avatar asked Feb 04 '15 02:02

MLQ


1 Answers

You can't do it. There are many things that can't be done in the visual format syntax; this is just one of them. The visual format syntax is good for what it's good for, but it can perform only quite a small subset of the most commonly needed settings of which constraints are capable. Just to give another example, you can't use it to set a center constraint.

There's nothing wrong with mixing and matching visual format syntax constraints with single constraints or other constraint commands. In your case, just send the view the setContentCompressionResistancePriority:forAxis: command or the setContentHuggingPriority:forAxis: command, and move on.

like image 107
matt Avatar answered Nov 16 '22 20:11

matt