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

后端 未结 4 1775
再見小時候
再見小時候 2021-02-03 17:04

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

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 17:50

    Starting with iOS 6, there's a new API, available in Interface Builder as well called 'Auto Layout'. You can specify some contraints and UIKit will resize / move your views based on those contraints. If you don't want to use Autolayout you can use the autoresizeMask property of UIViews (which is settable in Interface Builder as well).

    Check out the Autolayout Guide!

    To resize the views in Interface Builder as you build them, see the reply from @Fogmeister

提交回复
热议问题