0Pricing
SwiftUI Academy · Lekcja

Pasek narzędzi i tytuł nawigacji

Proszę dodawać tytuły i przyciski paska narzędzi do pasków.

Pasek narzędzi i tytuł nawigacji to bezpłatna lekcja SwiftUI Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej SwiftUI Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Naming the Screen

Every screen deserves a clear name. The navigationTitle modifier puts a heading in the navigation bar so users always know where they are. 🧭

.navigationTitle("Inbox")

Where the Title Goes

Attach navigationTitle to the content inside the NavigationStack, not to the stack itself. The bar then reads the title from the current screen.

NavigationStack {
    List { }
        .navigationTitle("Inbox")
}

Large vs Inline

By default the title is large and shrinks as you scroll. Use navigationBarTitleDisplayMode to force a compact inline style instead.

.navigationBarTitleDisplayMode(.inline)

Adding Toolbar Buttons

The toolbar modifier lets you place buttons in the navigation bar, like an add button or an edit action for the current screen.

.toolbar {
    Button("Add") { addItem() }
}

Choosing a Placement

Wrap each control in a ToolbarItem and pick a placement so buttons land on the correct side of the bar.

.toolbar {
    ToolbarItem(placement: .topBarTrailing) {
        Button("Add") { }
    }
}

Leading and Trailing

Use topBarLeading for the left edge and topBarTrailing for the right. These adapt automatically for right-to-left languages. 🌍

Icons in the Bar

Toolbar buttons often use SF Symbols instead of words to stay compact. A small image keeps the bar tidy on every device.

Button {
    addItem()
} label: {
    Image(systemName: "plus")
}

Many Buttons at Once

You can add several ToolbarItem entries in one toolbar block, grouping related actions like edit, share, and add together.

The Bottom Toolbar

Placement is not limited to the top. Use bottomBar to pin actions to the bottom of the screen for thumb-friendly controls.

ToolbarItem(placement: .bottomBar) {
    Button("Done") { }
}

Titles Follow the Stack

Each pushed screen sets its own title, and the bar updates as you navigate. The previous title even becomes the back button label.

Keep Bars Uncluttered

Resist filling the bar with buttons. Two or three clear actions keep the screen calm and easy to scan.

Quick Check

Which modifier adds buttons to the navigation bar?

Recap: Toolbar & Title

You name screens with navigationTitle and add buttons with toolbar and ToolbarItem placements. Up next, driving navigation entirely from code. 🚀

Często zadawane pytania

Czy lekcja „Pasek narzędzi i tytuł nawigacji” jest bezpłatna?

Tak — pełny tekst „Pasek narzędzi i tytuł nawigacji” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu SwiftUI Academy, przejdź na CoddyKit PRO. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Pasek narzędzi i tytuł nawigacji”?

Proszę dodawać tytuły i przyciski paska narzędzi do pasków. Ćwiczysz SwiftUI Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć SwiftUI Academy?

Nie wymagamy żadnego doświadczenia. SwiftUI Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.

Ile czasu zajmuje lekcja „Pasek narzędzi i tytuł nawigacji”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji SwiftUI Academy?

Tak. Każda lekcja SwiftUI Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Otwieranie ekranów za pomocą NavigationLink
  2. Przekazywanie danych do widoków szczegółów
  3. Pasek narzędzi i tytuł nawigacji
  4. Programowe ścieżki nawigacji
← Powrót do SwiftUI Academy