Open FredericRuaudel opened 3 years ago
Hi !
Thanks for this useful project. It seems that I've found how to update this code to have the sidebar toggle button working on iPadOS by changing the display mode like this:
#if os(macOS) list.toolbar { Button(action: toggleSidebar) { Image(systemName: "sidebar.left") } } #else list.toolbar { Button(action: { UIApplication.shared.setFirstSplitViewPreferredDisplayMode(.oneBesideSecondary) }) { Image(systemName: "sidebar.left") } } #endif }
And to make it animated, just update the setFirstSplitViewPreferredDisplayMode() method like this:
setFirstSplitViewPreferredDisplayMode()
if let splitViewController = splitViewController { UIView.animate(withDuration: 0.3, delay: 0, options: []) { splitViewController.preferredDisplayMode = preferredDisplayMode } completion: { _ in } } else { DispatchQueue.main.async { UIView.animate(withDuration: 0.3, delay: 0, options: []) { splitViewController?.preferredDisplayMode = preferredDisplayMode } completion: { _ in } } }
Hope it helps anyone !
It works for iPadOS 14 & 15 but do nothing on iOS (aka on phones)
Hi !
Thanks for this useful project. It seems that I've found how to update this code to have the sidebar toggle button working on iPadOS by changing the display mode like this:
And to make it animated, just update the
setFirstSplitViewPreferredDisplayMode()
method like this:Hope it helps anyone !