how to make UILabel autosize text in storyboard (or interface builder), NOT programmatically

Doug Null picture Doug Null · Jun 14, 2013 · Viewed 57.4k times · Source

Every time I click-and-drag a UILabel to storyboard, and then add text to Text field, the text is cut off, so I then have to click-and-drag the UILabel to stretch it big enough so that the text appears.

I can't figure out how to make the UILabel automatically get big enough to fit the text.

This would save time while designing new views.

Answer

Fogmeister picture Fogmeister · Jun 14, 2013

On any element in Interface Builder you can select the element and hit...

Editor > Size to Fit Content (keyboard shortcut: CMD+=)

This will do a "sizeToFit" on the selected element. Labels will fit their text size, image view will resize to the image size, etc...