Conrad Scherb
Conrad Scherb

Reputation: 1056

Change side of SwiftUI .toolbar

How do you adjust the vertical height of the .toolbar with SwiftUI? As seen in the image below, the toolbar is way too large (all I need it to do is just to fit those three items):

Too large toolbar

            NavigationView {
            VStack{
                MapView()
                }.toolbar {
                    ToolbarItem(placement: .principal) {
                        HStack(spacing: 20) {
                            Text("Toolbar")
                            Divider()
                            Button(action: {}) {Image(systemName: "plus.circle")}
                            Divider()
                            Button(action: {}) {Image(systemName:"arrowshape.turn.up.left.circle") 
                            }
                        }
                    }
                
           }

Upvotes: 2

Views: 1561

Answers (1)

Harshil Patel
Harshil Patel

Reputation: 1474

struct ContentView: View {
        var body: some View {
            NavigationView {
                VStack{
                    MapView()
                }.toolbar {
                    ToolbarItem(placement: .principal) {
                    HStack(spacing: 20) {
                        Text("Toolbar")
                        Divider()
                    Button(action: {}) {Image(systemName: "plus.circle")}
                        Divider()
                    Button(action: {}) {Image(systemName:"arrowshape.turn.up.left.circle")
                        }
                    }
                }
            }
            .navigationBarTitle("", displayMode: .inline)
        }
    }
}

Result: enter image description here

Upvotes: 1

Related Questions