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-|
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.