简体   繁体   English

剪裁按钮文字,自动版式,iOS

[英]text of button is clipped, auto layout, ios

My purpose is to allow the button to grow in width up to a certain limit so that it can display a long title.Therefore, I am setting the constraint for my button using interace builder like below 我的目的是允许按钮的宽度增加到一定的限制,以便它可以显示较长的标题。因此,我使用如下所示的interace builder来设置按钮的约束 在此处输入图片说明

However, when I try to run and the result is unexpected : 但是,当我尝试运行时结果却是意外的: 在此处输入图片说明

Not quite why I am getting this. 不太为什么我要这个。 Can somebody point out what I am doing wrong here. 有人可以指出我在这里做错了吗。 Any comments are welcomed here. 任何意见都欢迎在这里。 Thanks 谢谢

Call sizeToFit on the button after you set the new title. 设置新标题后,在按钮上调用sizeToFit Your button is less than or equal to 60 points wide, so the constraints are satisfied. 您的按钮小于或等于60点宽,所以满足约束。 This method will force the button to resize. 此方法将强制调整按钮的大小。

You may also want to try adjusting the content compression priority and the priority on your width constraint - currently the higher priority constraint (your width) will win and then be set as close as possible to its constant value. 您可能还想尝试调整内容压缩优先级和宽度约束上的优先级-当前,较高优先级约束(您的宽度)将获胜,然后将其设置为尽可能接近其恒定值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM