Following the coding intro to SwiftUI a curiosity arose with regard to the toolbar placement in the view.
The first question is regarding the use of the toolbar modifier. The demo showed the buttons appearing at the top of the view, but they appear at the bottom of the view in my rendition, despite applying the modifiers to different blocks within the body calculated property. Any ideas as to why this would be would be appreciated.
Additionally, the question begs as to whether the .navigationBarItems modifier is to be replaced by the new toolbar modifier? Or, will it simply be added to the toolset?
The first question is regarding the use of the toolbar modifier. The demo showed the buttons appearing at the top of the view, but they appear at the bottom of the view in my rendition, despite applying the modifiers to different blocks within the body calculated property. Any ideas as to why this would be would be appreciated.
Additionally, the question begs as to whether the .navigationBarItems modifier is to be replaced by the new toolbar modifier? Or, will it simply be added to the toolset?
Code Block var body: some View { NavigationView { List { ForEach(store.sandwiches) { sandwich in SandwichCell(sandwich: sandwich) } .onMove(perform: moveSandwiches) .onDelete(perform: deleteSandwiches) HStack { Spacer() Text("\(store.sandwiches.count) Sandwiches") .foregroundColor(.secondary) Spacer() } } .navigationTitle("Sandwiches") .toolbar { #if os(iOS) EditButton() #endif Button("Add", action: makeSandwich) } Text("Select a sandwich") .font(.largeTitle) } }