Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Toolbar bottom iOS 16 – SwiftUI

I would like to have a bottom toolbar with SwiftUI.
The following is working in iOS 15, but not in iOS 16.
In iOS 16 the toolbar is not showing. (It’s working if I change the placement…)

Text("Content")
    .toolbar {
        ToolbarItemGroup(placement: .bottomBar) {
            Button("Greeting") { 
                print("Hello world!")
            }
        }
    }

Screenshots

Do you have any workaround for this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks!

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading