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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.