根据绑定/状态以编程方式显示iPad Swiftui侧边栏

发布于 2025-02-08 13:02:43 字数 737 浏览 1 评论 0原文

我已经看到了其他答案。似乎没有好的解决方案。以防万一,以为我会问是否有任何更改可以允许您默认情况下显示侧边栏或基于bool

如果我有一个包含两个视图的navigationView,我希望该侧边栏显示用户是否未登录:

struct ContentView: View {
    
    @State var isActive = true
    @State var genActive = false
    @State var loggedIn = false
    
    var body: some View {
        NavigationView {
            LogoView()
            GenericDataView(loggedIn: $loggedIn)
        }
    }
}

侧边栏会提出登录屏幕。最终,我希望侧边栏以用户的主屏幕在其后面模糊。下图。现在将基本登录汇总为应用程序的基础,因此无需在navigationLink等复杂性方面工作。

“

I've seen the other answers on this. Seems like there's no good solution. Just in case, thought I'd ask if there have been any changes that allow you to display the sidebar by default or based on a Bool.

If I have a NavigationView like this containing two views, I'd like the the sidebar to show if the user isn't logged in:

struct ContentView: View {
    
    @State var isActive = true
    @State var genActive = false
    @State var loggedIn = false
    
    var body: some View {
        NavigationView {
            LogoView()
            GenericDataView(loggedIn: $loggedIn)
        }
    }
}

The sidebar brings up the login screen. Ultimately, I'd like the sidebar to show with the user's main screen blurred out behind it. Image below. Just putting together the basic login now as a base for the app, so don't need to work in the complexity of NavigationLink, etc.

screenshot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文