gpt4 book ai didi

ios - 推送 QLPreviewController 并将 Translucent 设置为 false?

转载 作者:行者123 更新时间:2023-11-30 12:35:44 28 4
gpt4 key购买 nike

我无法禁用 QLPreviewController 的半透明属性。我已经尝试过:

 let preview = SideQLPreviewController()
preview.navigationController?.navigationBar.isTranslucent = false //before
self.navigationController?.pushViewController(preview, animated: false)
preview.navigationController?.navigationBar.isTranslucent = false //after
self.navigationController?.navigationBar.isTranslucent = false

并且已经尝试子类化和设置:

class SideQLPreviewController: QLPreviewController {

override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.isTranslucent = false
// Do any additional setup after loading the view.
}

但仍然没有成功 - 有什么想法吗?

最佳答案

如果您提供QLPreviewController,则根本没有导航 Controller 。像这样的东西可以工作:

class PreviewController: QLPreviewController {
var navigationBar: UINavigationBar? {
return view.recursiveSubviews.filter({ $0 is UINavigationBar }).first as? UINavigationBar
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationBar?.isTranslucent = false
}
}

extension UIView {
var recursiveSubviews: [UIView] {
var recursiveSubviews: [UIView] = []
for subview in subviews {
recursiveSubviews.append(subview)
recursiveSubviews.append(contentsOf: subview.recursiveSubviews)
}
return recursiveSubviews
}
}

关于ios - 推送 QLPreviewController 并将 Translucent 设置为 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42886797/

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