gpt4 book ai didi

ios - 在所有 View 之上添加呈现的 View Controller

转载 作者:行者123 更新时间:2023-11-28 07:23:24 26 4
gpt4 key购买 nike

我正在像这样在 Tabbar 上方添加一个正在播放的 View :

    let transition = CATransition()
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromLeft
miniPlayerView.view.layer.add(transition, forKey: nil)
appDelegate.window?.rootViewController?.addChild(miniPlayerView)
appDelegate.window?.addSubview(miniPlayerView.view)
miniPlayerView.didMove()

miniPlayerView.didMove() 我正在设置 View 的框架

view.frame = CGRect(x: 0, y: heightAvailable - height, width: frameWidth, height: height)

现在,当我点击 NowPlaying 时,我正在全屏显示它,它里面有一个按钮,它会显示一个底部弹出窗口,它出现在 MiniPlayerView View 后面

我尝试了多个代码来在所有 View 上方添加弹出式 Bottom Sheet ,但它不起作用

代码示例:

    let modal = ModalViewController()
let transitionDelegate = DeckTransitioningDelegate()
modal.transitioningDelegate = transitionDelegate
modal.modalPresentationStyle = .custom
present(modal, animated: true, completion: nil)

另外,我尝试使用这个库:https://github.com/ergunemr/BottomPopup

但问题似乎出在这两行:

appDelegate.window?.rootViewController?.addChild(miniPlayerView)
appDelegate.window?.addSubview(miniPlayerView.view)

如何在 miniPlayerView v 中首先显示呈现的 Bottomsheet View

最佳答案

在这里尝试我的代码,我在所有 View 的顶部显示警报。如果真的有帮助,请使用它。

DispatchQueue.main.async(execute: {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.windowLevel = UIWindow.Level.alert+1

let alert2 = UIAlertController(title: title, message: message, preferredStyle: .alert)
let defaultAction2 = UIAlertAction(title: "OK", style: .default, handler: { action in
})
alert2.addAction(defaultAction2)

window.makeKeyAndVisible()

window.rootViewController?.present(alert2, animated: true, completion: nil)
})

关于ios - 在所有 View 之上添加呈现的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57323847/

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