gpt4 book ai didi

ios - UIButton 水平居中,自动换行

转载 作者:可可西里 更新时间:2023-11-01 03:51:42 24 4
gpt4 key购买 nike

我在容器 (UIView) 中有两个 UIButton。它们都有相同的选项(按钮标题除外):

UIButton's options

但是当我在 iPhone 5S 上启动这个应用程序时,我得到如下结果:

UIButtons on iPhone 5S

我的问题是:为什么第一个按钮有水平居中的文本而第二个按钮没有?我希望他们都将标题水平居中。

您好,帕维尔

最佳答案

实际上,您的第一个按钮居中只是因为它的标题中有较短的单词。如果将第二个按钮的标题设置为第一个按钮,您将获得相同的结果。

需要通过代码设置文本对齐方式,使标题居中:

 [button.titleLabel setTextAlignment: NSTextAlignmentCenter];

关于ios - UIButton 水平居中,自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28560760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com