I am struggling to figure out how to turn my tabbar
based iPad app into a sidebar navigation based Catalyst
app. Similar to the screenshot that Apple shows:
You can see in the screenshot above the iPad app uses a tabbar
layout but the macOS
Catalyst app used a left sidebar navigation.
How can I do this and convert my iPad app to use a sidebar in macOS
?
You can do something like this
#if targetEnvironment(macCatalyst)
// here use the NavigationView + NavigationLinks to make the sidebar on macOS
#else
// here use the Tab Bar view.
#endif
You can use this to create entire alternate views if you need.
For example:
#if targetEnvironment(macCatalyst)
struct MyView: View {
var body: some View {
Text("Im in macOS")
}
}
#else
struct MyView: View {
var body: some View {
Text("Im in iOS")
}
}
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With