autolayout content hug

Say you've got button like this:

[       Click Me      ]
and you've pinned the edges to a larger superview with priority 500.

Then, if Hugging priority > 500 it'll look like this:

[Click Me]
If Hugging priority < 500 it'll look like this:

[       Click Me      ]
If superview now shrinks then, if the Compression Resistance priority > 500, it'll look like this

[Click Me]
Else if Compression Resistance priority < 500, it could look like this:

[Cli..]
If it doesn't work like this then you've probably got some other constraints going on that are messing up your good work!

E.g. you could have it pinned to the superview with priority 1000. Or you could have a width priority. If so, this can be helpful.

Editor > Size to Fit Content

猜你喜欢

转载自lizhuang.iteye.com/blog/2090548