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

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


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...


In Xcode 6.1, I had to set Content Compression Resistance Priority to a higher value, likely because I have other constraints that were conflicting, or causing the sizeToFit option to be disabled.

Content Compression Resistance PriorityBefore:BeforeAfter:After


For the text label:

Set Lines to 0

Set Height to Greater than or equal to 30 (or other value)

Now the height will be adjusted based on the lines number.