Navigation bar length

Hello, I’m getting a design error when making an app for MacOS. Could anyone tell me how to avoid this length difference between navigation bar and sidebar? I suppose the dividing line should have the same alignment.

Hi,

Can you share more info about the project?
Is it SwiftUI or AppKit?
How are you creating the sidebar and are you setting any frames or constraints?

Sarah

Hello, of course. The project is built in SwiftUI.
My @main view doesn’t have any frames, but my sidebar do as so:

var body: some View {
        NavigationView {
            VStack(alignment: .leading) { }
            .onAppear {
                loadAccounts()
                filterAccounts()
            }
            .listStyle(SidebarListStyle())
            .navigationTitle("Explore")
            .frame(minWidth: 250, idealWidth: 250, maxWidth: 300)
//            .toolbar {
//                ToolbarItem(placement: .navigation) {
//                    Button(action: toggleSidebar, label: {
//                        Image(systemName: "sidebar.left")
//                    })
//                }
//            }
            TableView(tableData: exercise.entries, accountName: "General Ledger", accountNumber: 0)
        }
        .frame(
            minWidth: 1200,
            idealWidth: 1200,
            maxWidth: .infinity,
            minHeight: 700,
            idealHeight: 900,
            maxHeight: .infinity)
    }

The first frame is suppose to change the sidebar length and the second the entire view, but the navigation title seems to be independent.

I don’t have your TableView, so I used Text views as placeholders in the sidebar and detail view and it all worked fine.

You have to set the navigationTitle on either the detail view or the NavigationView. It doesn’t do anything if you set it on the sidebar view.

So it looks to me like your TableView is doing something strange.
Try replacing it with a Text placeholder and if that solves the problem, then take a look at it and any frames for it or its components.

If that isn’t it, test removing views from the sidebar’s VStack and track down the problem that way.

Hope this helps,
Sarah

1 Like

Thank you very much Sarah, I really appreciate your help

1 Like