Search code examples
iosobjective-ciphoneautolayout

ios auto layout label positionning


I am working with the storyboard using auto layout.

I need a particular layout and I am not able to find a way to do it.

I have two UILabels, the first one regular and the second one bold (That's why I used two UILabels).

I need the second UILabel to be near the second. But if the second label does not have enough space to displayed, then I want it to wrap the text.

image in english, need to be wrapped

xcode


Solution

  • In your storyboard, set property of textfield as lines=0 give below constraints only

    1. Top leading trailing to supverview

    2. Height with relationship greaterthanequalto

    Note: don't give bottom constraint to label

    To make some part of label bold use NSAtrributeString. Don't take two labels.