Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

410
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda