Is it possible to center button text, if the button is located a in List?
struct HomeView: View {
var body: some View {
List {
ForEach(["1", "2"], id: \.self) {
Text("\($0)…").frame(maxWidth: .infinity, alignment: .center)
}
Button("Action button") {}
}
}
}
Result:
PS:
I tried this: .frame(maxWidth: .infinity, alignment: .center)
But it doesn't work
Found solution:
Button{}
label: {
Text("Action").frame(maxWidth: .infinity, alignment: .center)
}