gpt4 book ai didi

ios - 无论文本如何,UILabel 都会将大小调整为 0 的高度

转载 作者:行者123 更新时间:2023-11-28 18:53:02 25 4
gpt4 key购买 nike

我有一个具有以下约束的 UILabel

enter image description here

并且我将行数设置为 0。IB 上的布局如下所示。我希望这个 UILabel 根据我收到的文本动态扩展,它下面的 View 根据 UILabel 的高度被向下推。然而,事实并非如此。

enter image description here

如下所示,UILabel 根本没有出现。无论我将文本设置为什么,它的高度似乎都为 0。有谁知道我需要修改什么才能做到这一点?有谁知道为什么 UILabel 的高度为 0?

enter image description here

更新:

根据下面的评论,我尝试了一些事情。

  1. 自动换行,没有变化

  2. 在 UILabel 上添加高度限制,文本在第一行后被截断

  3. 具有大于或等于常量的高度约束,文本在第一行后仍会被截断

最佳答案

我根据您的要求创建了一个虚拟 View 。

enter image description here

  1. 按钮有固定的约束:前导宽度、高度、顶部空间。

  2. 对于标签:前导、尾随、topSpace 到按钮

enter image description here enter image description here

3.对于标签下方的 View :给标签提供前导、尾随、高度、顶部空间 enter image description here

  1. 所以这里标签的高度不是固定的,会根据文字变化。

enter image description here

关于ios - 无论文本如何,UILabel 都会将大小调整为 0 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37426770/

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