gpt4 book ai didi

ios - 标签文本对齐

转载 作者:行者123 更新时间:2023-11-29 01:19:44 25 4
gpt4 key购买 nike

我有一个标签,标签上设置的文本在运行时是动态的。我担心的是标签始终位于屏幕中心。为此,我采用标签起点为 0,宽度为屏幕宽度和文本对齐中心。但我有问题在开始之前,我在文本开始之前调整了一个按钮。我们如何使这个按钮在文本开始之前开始。我不是在 xib 中做代码。label.textAlignment = NSTextAlignmentCenter

最佳答案

您可以使用自动布局轻松完成此操作。

enter image description here

Drag an UILabel to xib and set constraints as follows.

1. Set align center X and align center Y to your label.
2. Set trailing space to superview >= 20.
3. Drag a UIButton left to your label and set horizontal spacing between them.
4. Set button's center Y aligned to label's center Y and set button's width to 50.
5. Finally set button's leading space to superview >= 20.

这将调整所有 iPhone 的按钮和标签。不要忘记将 numberOfLines 设置为 0。

关于ios - 标签文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34760534/

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