首页 > 解决方案 > 如何将 navigationTitle 与菜单按钮(toolbarItem)对齐?

问题描述

我有一个带有toolbarItem 按钮的navigationView 来阻止/报告用户。但是导航标题与菜单按钮不对齐...

有没有办法将它们水平对齐?

否则我将被迫放弃工具栏,只使用 HStack 作为标题。

在此处输入图像描述

                NavigationView{
                    VStack {
                       ...bunch of code
                    }
                    .navigationBarTitle(Text(model.matches[index].name).font(.subheadline), displayMode: .large)
                    .toolbar {
                        ToolbarItem(placement: .navigationBarTrailing) {
                            Menu(content: {
                                Text("Menu Item 1")
                                Text("Menu Item 2")
                                Text("Menu Item 3")
                            }, label: {Image(systemName: "ellipsis")})
                        }
                    }
                    //.ignoresSafeArea(.top)
                }

标签: swiftuitoolbar

解决方案


.navigationBarTitle(Text(model.matches[index].name).font(.subheadline), displayMode: .inline )


推荐阅读