gpt4 book ai didi

ios - 来自 xib 的多行 UILabel

转载 作者:行者123 更新时间:2023-11-29 13:10:33 25 4
gpt4 key购买 nike

在我的 awakeFromNib 函数中,我有:

[_descriptionLabel setLineBreakMode:UILineBreakModeWordWrap];
[_descriptionLabel setNumberOfLines:10];
[_descriptionLabel sizeToFit];

但我的标签看起来像这样:

UILabel

我知道我在正确的标签上设置了这些调用,因为没有这些行,文本显示为垂直居中而不是顶部对齐。如何使我的 UILabel 多行?

我还尝试了 setNumberOfLines:0

解决方案 我在 xib 文件中设置的宽度不正确。

最佳答案

  1. 尝试设置 [_descriptionLabel setNumberOfLines:0]; 将行数设置为自动。
  2. 可能是 sizeToFit 正在更改您的标签宽度,请尝试将其设置为显式宽度,或将其删除。

关于ios - 来自 xib 的多行 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17507035/

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