This code worked in Xcode 12.0 B1 but no longer works in B2.
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach (1..<10) {
row in
Text("\(row) - Test").foregroundColor(Color.white).fontWeight(.bold)
}
.listRowBackground(Color.burgundy)
}
.navigationTitle(Text("List Background Color Test"))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .bottomBar) {
HStack {
Button(action: {}, label: {
Text("One").foregroundColor(Color.white)
})
Spacer()
Button(action: {}, label: {
Text("Two").foregroundColor(Color.white)
})
Spacer()
Button(action: {}, label: {
Text("Three").foregroundColor(Color.white)
}).foregroundColor(.blue)
}
}
}
}
}
}
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach (1..<10) {
row in
Text("\(row) - Test").foregroundColor(Color.white).fontWeight(.bold)
}
.listRowBackground(Color.burgundy)
}
.navigationTitle(Text("List Background Color Test"))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .bottomBar) {
HStack {
Button(action: {}, label: {
Text("One").foregroundColor(Color.white)
})
Spacer()
Button(action: {}, label: {
Text("Two").foregroundColor(Color.white)
})
Spacer()
Button(action: {}, label: {
Text("Three").foregroundColor(Color.white)
}).foregroundColor(.blue)
}
}
}
}
}
}
Apparently, it needs to be like this now, with each being embedded in a separate ToolbarItem including Spacer() - (found this while searching UIToolbar in SwiftUI):
.toolbar {
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("One")
})
}
ToolbarItem(placement: .bottomBar) {
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("Two")
})
}
ToolbarItem(placement: .bottomBar) {
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("Three")
})
}
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("One")
})
}
ToolbarItem(placement: .bottomBar) {
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("Two")
})
}
ToolbarItem(placement: .bottomBar) {
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button(action: {}, label: {
Text("Three")
})
}
}