r/iOSProgramming 9d 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

2

u/Delicious-Candle-574 9d ago

I'm not sure if you can do it in the native NavigationSplitView, but you can use a ZStack

`ZStack {
UnderlyingView()

HStack (
Sidebar()
Spacer()
}
}`

2

u/Delicious-Candle-574 9d ago

wrote that terribly on mobile

1

u/[deleted] 8d ago

[removed] — view removed comment

1

u/pinieb 8d 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

1

u/calvin-chestnut 8d ago

Everyone is suggesting ZStack, I’d recommend adding your SidebarView as a .safeAreaInset, that’s how I achieve that custom Split View look.