【发布时间】:2021-09-28 15:34:39
【问题描述】:
如果按钮位于列表中,是否可以将按钮文本居中?
struct HomeView: View {
var body: some View {
List {
ForEach(["1", "2"], id: \.self) {
Text("\($0)…").frame(maxWidth: .infinity, alignment: .center)
}
Button("Action button") {}
}
}
}
结果:
PS:
我试过这个:.frame(maxWidth: .infinity, alignment: .center)
但它不起作用
【问题讨论】: