gpt4 book ai didi

swift - 如何快速修复导航栏下的 View

转载 作者:行者123 更新时间:2023-11-30 10:50:40 25 4
gpt4 key购买 nike

我使用 EzPopup 库制作弹出窗口,当我将弹出窗口放在导航栏下时遇到问题。这是我的代码

@IBAction func showTopRightButton(_ sender: Any){
guard let pickerVC = pickerVC else { return }

pickerVC.delegate = self

let popupVC = PopupViewController(contentController: pickerVC, position: .topRight(CGPoint(x: 0, y: navigationController!.navigationBar.frame.height+20)), popupWidth: 100, popupHeight: 200)

popupVC.cornerRadius = 5
present(popupVC, animated: true, completion: nil)
}

我遇到了像我的图片一样的问题 enter image description here

如何在 iphone x 和 iphone x 中制作相同的内容

最佳答案

在 iPhone X 纵向模式下,状态栏更高 — 44 点,而不是 20 点

您还需要添加状态栏框架高度。尝试下面的代码:

//1.0 Get the Top bar height
let topBarHeight = UIApplication.shared.statusBarFrame.size.height + (self.navigationController?.navigationBar.frame.height ?? 0.0)

let popupVC = PopupViewController(contentController: pickerVC, position: .topRight(CGPoint(x: 0, y: topBarHeight)), popupWidth: 100, popupHeight: 200)

您可以阅读有关 UILayout 的更多信息 here .

关于swift - 如何快速修复导航栏下的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54616734/

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