Member-only story
The Navigation Bar Isn’t Hidden as Expected in SwiftUI
Are your buttons not tappable? Here’s an easy fix.

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.
If you’re not that rushed, feel free to read my full article with a cup of coffee.
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:
- 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
2. The Situation
You might think of using native navigationBarItems
to provide a leading item and trailing item, like this:
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…