查看窗口右侧的显示

发布于 2025-01-10 15:22:27 字数 918 浏览 0 评论 0原文

你好,当我使用导航视图时,我的 Xcode 项目出现问题,窗口显示不正常,并且出现在已显示窗口的右侧,

这是代码。

NavigationLink(destination: Acceuil())
                        {
                            HStack{
                               Image("icone_connexion")
                                    .font(.system(size: 15))
                                 //   .scaledToFill()


                                Text("se connecter")
                                        .font(.system(size: 30))
                          
                            }.cornerRadius(60)
                           .frame(width: 400, height: 60)
                            
                        } .background(Capsule().fill(Color(red: 55/255, green: 66/255, blue: 114/255, opacity:1)))
                        .frame(width: 400, height: 60) //fin navigationlink
                        .buttonStyle(PlainButtonStyle())

我希望新窗口取代旧窗口:)

hello i have an issue with my project on Xcode when I use navigation view, the window display not normally and appear on the right of the window already displayed,

here is the code.

NavigationLink(destination: Acceuil())
                        {
                            HStack{
                               Image("icone_connexion")
                                    .font(.system(size: 15))
                                 //   .scaledToFill()


                                Text("se connecter")
                                        .font(.system(size: 30))
                          
                            }.cornerRadius(60)
                           .frame(width: 400, height: 60)
                            
                        } .background(Capsule().fill(Color(red: 55/255, green: 66/255, blue: 114/255, opacity:1)))
                        .frame(width: 400, height: 60) //fin navigationlink
                        .buttonStyle(PlainButtonStyle())

I would like that the new window replace the older one:)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

依 靠 2025-01-17 15:22:27

在 macOS 上,NavigationView 中的标准行为是相邻显示视图(父视图和目标视图):https://developer.apple.com/design/ human-interface-guidelines/macos/windows-and-views/column-views/

如果您不希望这样做,您可以这样做:

    NavigationView {
        ...
    }
    .navigationViewStyle(.stack)

On macOS it is the standard behavior in NavigationView to show the views (parent view and destination view) next to each other: https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/column-views/

If you don't want that you can do:

    NavigationView {
        ...
    }
    .navigationViewStyle(.stack)
转瞬即逝 2025-01-17 15:22:27

所以我发现这段代码

 import SwiftUI

    struct ContentView: View {
        @State private var show = false
        var body: some View {
            VStack{
                if !show {
                    RootView(show: $show)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.blue)
                        .transition(AnyTransition.move(edge: .leading)).animation(.default)
                }
                if show {
                    NextView(show: $show)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.green)
                        .transition(AnyTransition.move(edge: .trailing)).animation(.default)
                }
            }
        }
    }

    struct RootView: View {
        @Binding var show: Bool
        var body: some View {
            VStack{
                Button("Next") { self.show = true }
                Text("This is the first view")
            }
        }
    }

对我来说很有效所以感谢您的帮助

so I found this code

 import SwiftUI

    struct ContentView: View {
        @State private var show = false
        var body: some View {
            VStack{
                if !show {
                    RootView(show: $show)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.blue)
                        .transition(AnyTransition.move(edge: .leading)).animation(.default)
                }
                if show {
                    NextView(show: $show)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.green)
                        .transition(AnyTransition.move(edge: .trailing)).animation(.default)
                }
            }
        }
    }

    struct RootView: View {
        @Binding var show: Bool
        var body: some View {
            VStack{
                Button("Next") { self.show = true }
                Text("This is the first view")
            }
        }
    }

it work grate for me so thanks you for your help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文