gpt4 book ai didi

ios - 如何在 Xcode 6 的 iOS 中使用 Storyboard执行 self.view.frame.size.width?

转载 作者:行者123 更新时间:2023-11-29 10:20:58 27 4
gpt4 key购买 nike

我想将 subview 的宽度设置为与 super View 的宽度相同。以编程方式使用 self.view.frame.size.width 我们可以在 CGRectMake 中分配。

但是,如何使用 Storyboard 来做同样的事情呢?如果可以使用约束,则列出步骤。

最佳答案

您需要像在 xib 中那样做。只需创建 subview 的 IBOutlet。并给出关于 superview 的大小。例如,

我假设您已经创建了名称为 subview1 的 subview 导出。

IBOutlet UIView *subview1;

现在根据您的需要设置框架。

subview1.frame=CGRectmake(0,0,self.view.frame.size.width,self.view.frame.size.height);

就是这样。

编辑:- 对不起,我忘了读到你必须设置约束。

enter image description here

关于ios - 如何在 Xcode 6 的 iOS 中使用 Storyboard执行 self.view.frame.size.width?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35309571/

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