如何使UILabel在storyboard(或界面构建器)中自动调整文本,而不是以编程方式 [英] how to make UILabel autosize text in storyboard (or interface builder), NOT programmatically

查看:467
本文介绍了如何使UILabel在storyboard(或界面构建器)中自动调整文本,而不是以编程方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我点击并拖动UILabel到故事板,然后将文本添加到文本字段时,文本就会被截断,因此我必须单击并拖动UILabel以将其拉伸得足够大以便文字出现。

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.

我无法弄清楚如何使UILabel自动变得足够大以适应文本。

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.

推荐答案

开在Interface Builder中你可以选择元素并点击...

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

编辑器>适合内容的大小(键盘快捷键: CMD + < kbd> = )

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

这将对所选元素执行sizeToFit。标签将适合其文字大小,图像视图将调整为图像大小等...

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

这篇关于如何使UILabel在storyboard(或界面构建器)中自动调整文本,而不是以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆