Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

417
Views
SwiftUI `navigationBarItems` vs `toolbar` what are the differences?

What are the differences between navigationBarItems vs toolbar in SwiftUI? I've been using them interchangeably and feel like they are doing the same things with different syntax, eg: put buttons on navigationBar (.leading/.trailing).

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

As mentioned by Lorem Ipsum, .toolbar is the way to go forward. The biggest difference is that .navigationBarItems is iOS/iPad OS only, whereas .toolbar works on macOS as well.

This makes it much easier to create universal views.

If you're just targeting mobile devices, there isn't really any difference in outcome at the moment.

over 4 years ago · Santiago Trujillo Report

0

.toolbar will (by default) automatically display the button on the leading or trailing edge depending on the locale.

.toolbar(
    Button("Edit") {
        print("Editing ...")
    }
)

This will show the button on the trailing edge for left- to-right languages, or on the leading edge for right-to-left. You can put it where you want by wrapping it in a ToolbarItem().

.toolbar(
    ToolbarItem(placement: .navigationBarLeading) {
        // Button
    }
)
over 4 years ago · Santiago Trujillo Report

0

In addition to what has been said: .toolbar requires iOS 14. A lots of projects need to be backward-compatible to iOS 13 and then navigationBarItems is the only way to achieve this

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!