gpt4 book ai didi

ios - 如何设置根 Stack View 的乘数值(与 super View 的宽度相等,乘数为 0.7)iPhone 为 0.7,iPad 为 0.6?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:34:28 24 4
gpt4 key购买 nike

我为根堆栈 View 做了一个基于百分比的宽度。

首先,我使根堆栈 View 与 super View 的宽度相等,乘数为 0.7,以获得 70% 的 subview 。然后在容器中水平居中。它适用于所有 iPhone,但对于 iPad 来说更大。我想让乘数从 0.7 到 0.5 或 0.6,这样 Root View 就可以完美地显示在 iPad 上。

我没有在乘数旁边找到 +(加号)符号来创建它(iPad 的常规 - 常规)。

我只想让根堆栈 View 获得所有 iPhone 的 super View 宽度的 60% 和所有 iPad 的 super View 宽度的 70%。

有没有办法改变 iPhone 的乘数 0.7 和 iPad 的 0.6?

最佳答案

当然可以!它可以通过大小类轻松实现,但不幸的是,您必须为不同的大小类添加另一个约束,而不是为同一约束添加不同的乘数

1) 假设您有这样的观点: enter image description here

2) 你所要做的就是添加另一个 subview -父 View 等宽约束:

enter image description here

enter image description here

3) 当然,得到冲突的约束:

enter image description here

4) 为新约束设置 iPad (0.6) 所需的乘数

5) 棘手的部分:为除 Regular WidthRegular Height(iPad 尺寸类)之外的所有 Size 类启用旧约束,反之亦然用于新约束:

5.1) 为第一个约束添加 wR hR “变体”: enter image description here

并禁用它: enter image description here

对第二个约束执行相同的操作,但为“安装”变体禁用它。

最后两个常量应该是这样的:

enter image description here

enter image description here

如您所见,如果我们预览 iPhone,我们只会看到第一个约束被激活,在 iPad 预览中只会看到第二个约束被激活。

关于ios - 如何设置根 Stack View 的乘数值(与 super View 的宽度相等,乘数为 0.7)iPhone 为 0.7,iPad 为 0.6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41622088/

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