【发布时间】:2020-12-06 01:21:35
【问题描述】:
我想在我的NavigationView 中的.toolbar 的.bottomBar 上添加一个“撰写”按钮。
添加一个Spacer() 只是几乎中心对齐项目:
struct HomeView: View {
var body: some View {
NavigationView {
Text("Hello, World!")
.navigationTitle("Hello, World!")
.toolbar {
ToolbarItem(placement: .bottomBar) {
HStack {
Spacer()
Button(action: { print("Pressed") }) {
Image(systemName: "plus.circle.fill")
.imageScale(.large)
.font(.title)
}
}
}
}
}
}
}
这会产生以下内容:
不是我所期望的。更奇怪的是,它并没有完全居中对齐,它偏离了几个像素。
那我该怎么做:
-
右对齐?
-
居中对齐?
谢谢
【问题讨论】: