Ios 隐藏故事板的切换
在我的应用程序中,我有两个故事板:onboard和Main。当用户第一次打开应用程序时-将显示“在线”情节提要。之后,他按下一个按钮,我向他展示带有以下代码的Main故事板:Ios 隐藏故事板的切换,ios,swift,uiviewcontroller,uistoryboard,uipresentingcontroller,Ios,Swift,Uiviewcontroller,Uistoryboard,Uipresentingcontroller,在我的应用程序中,我有两个故事板:onboard和Main。当用户第一次打开应用程序时-将显示“在线”情节提要。之后,他按下一个按钮,我向他展示带有以下代码的Main故事板: let storyboard = UIStoryboard(name: "Shop", bundle: nil) let navigationVc = storyboard.instantiateViewController(withIdentifier: "ShopScreens") as UIViewControlle
let storyboard = UIStoryboard(name: "Shop", bundle: nil)
let navigationVc = storyboard.instantiateViewController(withIdentifier: "ShopScreens") as UIViewController
navigationVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(navigationVc, animated: false, completion: nil)
我想在用户切换故事板时制作自定义动画。为此,我创建了一个简单的视图,并将其呈现在如下内容之上:
UIApplication.shared.keyWindow?.addSubview(self.containerViewForAnimatedView)
这个视图工作得很好,但仅就一个故事板而言,它涵盖了应用程序更改屏幕时的所有内容
但当我尝试切换故事板时,这个视图会被新呈现的故事板所覆盖
我还尝试以这种方式表达观点,并将其带到前面:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.addSubview(self.containerViewForAnimatedView)
但这也不管用
在转换过程中,如何通过显示自定义创建的视图来隐藏故事板的切换?
非常感谢您的帮助。只是用它玩了一些游戏,没有动画或任何特别的东西,但这将为您提供您想要的流程:
class ViewController: UIViewController {
let viiew = UIView.init(frame: UIScreen.main.bounds)
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.viiew.backgroundColor = .blue
UIApplication.shared.keyWindowInConnectedScenes?.resignKey()
UIApplication.shared.keyWindowInConnectedScenes?.addSubview(self.viiew)
self.viiew.layer.zPosition = 1000
}
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
let vc = ViewController2()
UIApplication.shared.keyWindowInConnectedScenes?.rootViewController = vc
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
self.viiew.removeFromSuperview()
}
}
}
}
class ViewController2: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .green
}
}
extension UIApplication {
var keyWindowInConnectedScenes: UIWindow? {
return windows.first(where: { $0.isKeyWindow })
}
}
所以你有情节提要1,想在上面显示一个视图,然后用情节提要2替换该视图下面的情节提要1?@Vollan正确,然后-删除我错过的视图-
self.viiew.layer.zPosition=1000
,在将它添加到我的视图后,它成功了!非常感谢你的帮助!