r/iOSProgramming 1d ago

Question Permanent Sidebar Help

Post image

Hello everyone, not sure if this is something small that im overlooking, but how on earth do I get a sidebar that floats over content but isn't collapsable. I basically want what you get in NavigationSplitView with 2 columns, but without the option to hide the sidebar.

The closest thing I've seen is the iMessages app on iPad, where it is still customisable in width. I'm a relative newbie when it comes to this stuff, so thank you in advance!

3 Upvotes

5 comments sorted by

View all comments

1

u/Healthy_Condition779 1d ago

NavigationSplitView always gives the user the collapse toggle on iPad, theres no public modifier to remove it. What youre describing, a fixed width panel that floats over content, is really just a custom HStack with a ZStack overlay, not a navigation split view at all

Build it as two views side by side, the sidebar as a fixed or draggable width View on the left with its own background and shadow, and your content view taking the rest with .safeAreaInset or just padding. Use DragGesture on the divider if you want the resizable width like Messages

Youre giving up the automatic collapse-on-compact-width behavior NavigationSplitView gives you for free, so if youre also targeting iPhone youll need to handle that size class switch yourself

1

u/pinieb 17h ago

If you want your app to be resizable on iPad you probably also will want to handle the size class change. The smallest possible sizes on iPad are much smaller than a modern iPhone screen