简体   繁体   中英

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):

工具栏太大

            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") 
                            }
                        }
                    }
                
           }
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: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM