gpt4 book ai didi

ios - 具有尺寸等级的 UIStackView subview

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:36:29 25 4
gpt4 key购买 nike

尝试使用尺寸等级为 iPhone 实现 2 个标签,为 iPad 使用 3 个标签实现 UIStackView。

查看层次结构

  1. 默认尺寸等级

    [UIStackView] 
    [UILabel 1] [UILabel2]
    [UIStackView]

    enter image description here

  2. RxR 尺寸等级

    [UIStackView] 
    [UILabel 1] [UILabel2] [UILabel3]
    [UIStackView]

    enter image description here

如您在上面的屏幕截图中所见,它在 Storyboard 中看起来完全符合预期,但在模拟器 iPad 上的 View 却乱七八糟。

iPhone 输出(好的)

enter image description here

iPad 纵向输出(搞砸了)

enter image description here

iPad 横向输出(搞砸了) enter image description here

iPad 上发生了什么??是错误还是我遗漏了什么?谢谢。

我创建了一个 sample project .

最佳答案

按照以下步骤实现您的要求:

  • 将一个水平 Stackview 拖到您的界面构建器中
  • 设置如下约束:top,leading, =trailing and fixed height
  • 将三个标签拖放到其中并一起选择并设置一个约束:Equal width
  • 现在选择第二个或中间标签,然后从 attribute inspector 单击 installed 旁边的 + 按钮,然后为宽度和高度选择 Regular。它将添加规则的、规则的变化并取消选中该 R,R 变化的复选框。请参阅下面的屏幕截图以更好地理解,

enter image description here

大功告成!现在你的中心标签将不会显示在 iPad 中,每个标签都会显示在 iPhone 中!

在我的案例中,请参见下面的 iphone 和 ipad 结果截图!

苹果手机:

enter image description here

iPad:

enter image description here

更新:

如果你想让两个标签在 iPhone 中隐藏并在 iPad 中显示,那么再添加一个变体:Compact Width Regular Height 用于中间标签并取消选中复选框以卸载。引用下面的截图,

enter image description here

关于ios - 具有尺寸等级的 UIStackView subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47286134/

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