WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

SwiftUi, hiding the sidebar and program state.

Forums > SwiftUI

This may be a relatively beginners question, but I have a Mac app that displays some items in its details view when you click on the library option in the sidebar. All well and good. However the sidebar isnt really that important to the app. It has the Library link, a FAQ link, settings, logout, and preferences. The library is automatically selected and its where the user is going to be 90% of the time.

I want to stick with standard SwiftUI flow nevertheles, everything in a NavigationView., so I dont really want a single document based page with those options on a toolbar or a menu.


1) Can I open with the sidebar closed on first launch? 2) Program state is not being preserved in any case so if I close the sidebar it comes back. How to fix this?

Any thoughts?


You could consider .navlgationViewStyle(.stack), then programmatically have a method to select whether to see the stacked or unstacked view, using Group to collect the views.


Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.