微信h5隐藏导航栏和状态栏
TL;DR: If you can’t tap on buttons in the navigation-bar area, you can jump directly to “4. The Solution” to fix the issue.
TL; DR:如果无法点击导航栏区域中的按钮,则可以直接跳至“ 4。 解决方案”。
If you’re not that rushed, feel free to read my full article with a cup of coffee.
如果您不那么着急,请随时阅读一杯咖啡来阅读我的全文。
1.要求 (1. The Requirements)
On a nice day, you’re tasked with implementing a custom navigation bar in your new iOS app. With SwiftUI, you’re confident you can get it done within just an hour because it’s really simple, as it needs only two buttons:
在美好的一天,您的任务是在新的iOS应用中实现自定义导航栏。 使用SwiftUI,您有信心可以在一个小时内完成它,因为它非常简单,因为它只需要两个按钮:
Back button: To let users go back to the previous screen
后退按钮 :让用户返回上一屏幕
Close button: To let users dismiss the current flow and dismiss to the first screen of the flow
关闭按钮 :让用户关闭当前流程并转到流程的第一个屏幕
![Image for post](https://miro.medium.com/max/9999/1*htqlLbzivjI7yRo-LWog1A.png)
2.情况 (2. The Situation)
You might think of using native navigationBarItems
to provide a leading item and trailing item, like this:
您可能会想到使用本机navigationBarItems
提供前导项和尾随项,如下所示:
var body: some View {
VStack {
EmptyView()
}
.navigationBarItems(leading: backButton, trailing: closeButton)
.background(Color.white)
.edgesIgnoringSafeArea(.all)
}
With the back button as the leading button and the close button, you’re confident running the code. Oops! There’s another unexpected blue back button there.
使用后退按钮作为前导按钮,然后使用关闭按钮,您可以自信地运行代码。 糟糕! 那里还有一个意外的蓝色后退按钮。
![Image for post](https://miro.medium.com/max/9999/1*OVfwFJ_hwhFq0KQ1zqkV-g.png)
Simple! You think, “We can hide the native back button in just a second!” Stop there for a moment — you already replaced the leading button as your custom back button. Why is the native bl