gpt4 book ai didi

ios - 在运行时根据设备更改约束

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:15 25 4
gpt4 key购买 nike

我正在使用 Storyboard 来设置我的约束。虽然一切都很完美,但我有一些观点,我希望更改仅对 3.5"设备的限制。

这可能吗?我该怎么做?

最佳答案

您可以定义一个宏来确定屏幕尺寸,如下所示:

#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE

在代码的后面你可以做这样的事情:

if (isiPhone4) {
self.constraint.constant = NEW_VALUE;
}

要从代码访问 Storyboard 约束,您应该为它们创建 IBOutlets(像其他任何操作一样,按住 control+将它们拖到您的 Controller 中)。

enter image description here

关于ios - 在运行时根据设备更改约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21748156/

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