swiftui - 如何将 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)
}
解决方案
.navigationBarTitle(Text(model.matches[index].name).font(.subheadline), displayMode: .inline )
推荐阅读
- c++ - C++内联运算符重载,引用当前对象
- django - 为什么我不能在 django/sqlite 中更改我的数据库对象?
- c++ - 在 C++ 中比较两个整数的最有效和最干净的方法是什么?
- mongodb - 如何访问 MongoDB 中的嵌套数组?
- flask - 在烧瓶中提交表单时出现错误请求错误
- php - Pusher 客户端 /pusher/auth 返回错误 500(内部服务器错误)
- ruby - Ruby - 未定义的局部变量
- html - 需要重现特定的 HTML 表格
- python - Python将字符串矩阵转换为浮点矩阵
- javascript - DJANGO - 将 POST 数据转换为 JSON 并部分呈现 HTML