Question

I have several UILabels of various sizes on my Views. I want all the UILabels to have the same font size no matter how wide or tall my UILabels are. I have tried several settings in IB but nothing seems to get me that fixed font size. I am sure I am missing something simple. Can someone please clue me in?

Was it helpful?

Solution 2

I found the answer to my question. Click on the UILabel in IB and then go to the menu Font > Show Fonts (or Cmd-T). There you can see the exact font you want per UILabel.

OTHER TIPS

Turn off "Adjust to fit" in the Font Size preferences of the Label Attributes. Or set label.adjustsFontSizeToFitWidth = NO;

You can increase minimum size of labels in Interface Builder.

Deselect the "Adjust to fit" checkbox in the Font Size category in IB.

In Interface Builder, select your UILabel, then click on the third tab on the inspector (View Size). Assuming size and position values are ok, you need to adjust the values in the Autosizing pane as follows: deselect every red edge, both inside and outside of the internal square. When you do this, you will see immediately the related behaviour in the right rectangle showing your UILabel object when its bounds change by resizing it. Basically, as you will notice, your UILabel dimension will stay the same. This should be enough.

You can try experimenting by yourself the effect of setting some of the edges, and observing the resulting effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top