gpt4 book ai didi

ios - swift : addSubview before StoryBoard

转载 作者:行者123 更新时间:2023-11-30 13:43:38 25 4
gpt4 key购买 nike

我对 swift 并不陌生,但对使用 Storyboard不熟悉,我通常以编程方式完成所有操作,但决定对其进行一些更改。

我有一个带有一堆 UIButtons(数字 0 - 9,类似于计算器)的 Storyboard,我想在添加所有按钮之前在最低层添加一个 View 。所以就层而言: UIView -> UIButtons

我认为简单地添加 viewDidLoad() 并将 View 放在第一位就可以了,但事实并非如此:

override func viewDidLoad() {

blurView = BlurViewEffect(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height))
self.view.addSubview(blurView)

designButtons()
}

知道如何最后加载 Storyboard吗?

最佳答案

viewDidLoad 方法之前无法加载 Storyboard。 Storyboard被序列化,因此基本上它们是使用 init:coder 方法加载的。

但是,典型的布局工具应该可以满足您的需求。只需使用 view.sendSubviewToBack(blurView) 即可确保您的blurView位于 View 的后面。

关于ios - swift : addSubview before StoryBoard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35250860/

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