As mentioned in the comments by @Nirav D, this button is used to toggle the sidebar visibility.
In iOS 16, Apple gave Navigation a big refresh:
NavigationStack
(which is probably what you want), it is used to present a view allowing the user to navigate using NavigationLink
as you would on an iPhone.NavigationSplitView
(which is what you’re seing in the simulator right now), it is used to present a menu (sidebar) that can present detail views. You can have up to 3 columns.NavigationView
, from now on you have to use the above containers as NavigationView
will be obsoleted in a future iOS release.In versions earlier than 16, you have to use NavigationView
. NavigationView
accepts navigationViewStyle
, the default style on iPhone is StackNavigationViewStyle
where the content is presented in one column. However, on iPad in order to maximise the use of screen estate, SwiftUI sets the default style to ColumnNavigationViewStyle
that presents the content in columns (Master -> Detail…).
If you mean to use a single column: you must use either NavigationStack
or NaigationView
with .navigationViewStyle(.stack)
;
If you have to use multiple columns & still hide the button: use .navigationBarHidden(true)
on the sidebar view, or .toolbar(.hidden, for: .navigationBar)
for iOS 16+.
For more info, check: Navigation & The SwiftUI cookbook for navigation