【问题标题】:Tabbar iPad App to Sidebar macOS Catalyst appTabbar iPad App to Sidebar macOS Catalyst app
【发布时间】:2020-06-17 01:32:55
【问题描述】:

我正在努力弄清楚如何将基于 tabbar 的 iPad 应用程序转变为基于侧边栏导航的 Catalyst 应用程序。类似于苹果展示的截图:

您可以在上面的屏幕截图中看到 iPad 应用程序使用 tabbar 布局,但 macOS Catalyst 应用程序使用左侧边栏导航。

我怎样才能做到这一点并将我的 iPad 应用程序转换为在macOS 中使用侧边栏?

【问题讨论】:

    标签: ios xcode mac-catalyst


    【解决方案1】:

    你可以这样做

    #if targetEnvironment(macCatalyst)
        // here use the NavigationView + NavigationLinks to make the sidebar on macOS
    #else
        // here use the Tab Bar view. 
    #endif
    

    如果需要,您可以使用它来创建整个备用视图。

    例如:

    #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
    

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 1970-01-01
      • 2010-12-06
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 2021-04-05
      • 1970-01-01
      • 2020-02-24
      相关资源
      最近更新 更多