i have simple custom view , within wrapping label (multi line label) subview. used autolayout set constraints.
now want superview change size show content of wrapping label. how can achieve that? wrapping laben shows content of text field (outlet: "textfeld").
you need set content hugging & compression resistance constraints on label (among other constraints).
with label selected, select size inspector. @ bottom, you'll see constraints section:
these have default values of around 250 & 750. need boost these 1000. these constraints control way label grows & shrinks relative content, such low priority, every other autolayout constraint add take priority. need increase priority of these constraints 1000 marks them required (or @ minimum, need increase content compression resistance priorities).
now implement other autolayout constraints around make sense. example, if want have @ least 20 pixel border each side, 20 pixels top, , centered in superview, might set constraints this:
of course, these constraints, if parent view isn't constrained max width, won't have implicitly forced word wrapping, might expand parent view's width. can add max width constraint our label too.
Comments
Post a Comment