Increase height of toolbar swiftui
Asked Answered
S

0

7

Is there a way to increase the height of the SwiftUI toolbar? My toolbar items are quite squished together and if I add any padding then they are cut off from the view.

What I have done is created an empty text since I just want the toolbar, I then have one ItemGroup and some other Items of the toolbar. Each Item in the group has an image on top of the text. The text is very bunched up with the picture there

Below is the code for the toolbar:

    Text("").toolbar{
        ToolbarItemGroup{
            Button(action: printD){
                Label{
                    Text("Current Location")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "paperplane.fill")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)
                    
                }.labelStyle(VerticalLabelStyle())
            }
            Spacer()
            Button(action: printD){
                Label{
                    Text("Get Route")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "car.fill")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }
            Button(action: printD){
                Label{
                    Text("Add Place")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "plus")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }

            Button(action: printD){
                Label{
                    Text("Delete Place")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "trash.fill")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }

            Button(action: printD){
                Label{
                    Text("Tinted Area")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "square.split.bottomrightquarter")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }
            Spacer()

            Button(action: printD){
                Label{
                    Text("Zoom Map")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "map.fill")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }
            Spacer()
            Button(action: printD){
                Label{
                    Text("Share Actions")
                        .font(.caption2)
                } icon: {
                    Image(systemName: "arrowshape.turn.up.right.fill")
                        .foregroundColor(.orange)
                        .scaleEffect(1.5)

                }.labelStyle(VerticalLabelStyle())
            }
        }
        ToolbarItem{
            Menu {
                Button {
                    
                } label: {
                    Text("Linear")
                    Image(systemName: "arrow.down.right.circle")
                }
                Button {
                    
                } label: {
                    Text("Radial")
                    Image(systemName: "arrow.up.and.down.circle")
                }
            } label: {
                 Text("Style")
                 Image(systemName: "tag.circle")
            }
        }
        ToolbarItem {
            Text("").searchable(text: $searchText)
        }
    }.frame(height: 0)

Toolbar screenshot:

Spank answered 11/10, 2022 at 17:1 Comment(1)
Does this help with your situation? https://mcmap.net/q/1629222/-changing-custom-uinavigationbar-39-s-height-using-swift-or-swiftuiKairouan

© 2022 - 2024 — McMap. All rights reserved.