swift – Toolbar bottom iOS 16 – SwiftUI


toolbar depends on the navigation bar so you have to have a NavigationView/NavigationStack

https://developer.apple.com/documentation/swiftui/view/toolbar(content:)-5w0tj

struct ToolbarSolutionView: View {
    var body: some View {
        NavigationView{ //NavigationStack
            Text("Content")
            
                .toolbar {
                    ToolbarItemGroup(placement: .bottomBar) {
                        Button("Greeting") {
                            print("Hello world!")
                        }
                    }
                }
        }
    }
}

It was likely a bug that it was working before.

You can hide the navigation bar if you don’t need it.

//iOS 13+
.navigationBarHidden(true)

//iOS 16+
.toolbar(.hidden, for: .navigationBar)

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img