如何在导航栏swift ui中设置左右按钮(leading/trailing)?

How to set buttons in left and right(leading/trailing) in navigation bar swift ui?

我想在导航栏左边(leading)设置一个按钮,在右边设置一个按钮( swift ui.
中导航栏的 trailing)
请帮我做一下。

.navigationBarItems(leading:
  HStack {
   Button("About") {
    print("About tapped!")
   }
  }
 )

使用以下修饰符

.navigationBarItems(leading:
   Button("About") {
    print("About tapped!")
   },
 trailing: 
   Button("Settings") {
    print("Settings tapped!")
   }
)

尝试使用此代码设置多个按钮:

.navigationBarItems(
   leading:
     HStack {
       Button("About") {
         print("About tapped!")
       }
       Button("Call") {
         print("Call tapped!")
       }
     },

   trailing:
     HStack {
       Button("Settings") {
         print("Settings tapped!")
       }
       Button("Contacts") {
         print("Contacts tapped!")
       }           
     }
  )