Thursday, May 23, 2024
HomeiOS DevelopmentFlip off sidebar hiding on NavigationSplitView in SwiftUI

Flip off sidebar hiding on NavigationSplitView in SwiftUI


Printed on: Could 21, 2024

By default, a NavigationSplitView in SwiftUI will present customers an choice to toggle the visibility of the sidebar. If you wish to stop this button from exhibiting up in order that customers will all the time need to see your sidebar, you are able to do this by making use of the toolbar(eradicating:) view modifier to your break up view’s sidebar as follows:

NavigationSplitView(sidebar: {
  ExercisesList()
    .toolbar(eradicating: .sidebarToggle)
}, element: {
  ExerciseDetail(train: workouts.first!)
})

The draw back of doing that is that the button is hidden each in portrait and panorama modes. The result’s that panorama customers can not entry your app’s sidebar.

To repair this you may attempt making use of the view modifier conditionally based mostly on the machine’s orientation however that is not preferrred; apps in panorama may also present the break up view as a single column. I’ve but to discover a good, dependable answer to conditionally presenting and hiding the sidebar toggle.

One upside for customers is that they will nonetheless summon the sidebar in portrait mode by swiping from the vanguard of the display in direction of the center. It isn’t excellent, but it surely’s higher than nothing I suppose.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments