SwiftUI Academy · レッスン

Toolbar とナビゲーション タイトル

バーにタイトルとツールバー ボタンを追加します。

レッスン 3/413 ステップ

「Toolbar とナビゲーション タイトル」はCoddyKit上の無料SwiftUI Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSwiftUI Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 SwiftUI Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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. 🚀

無料で開始

AI チューターと学ぶ Swift — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
30
レッスン
120

よくある質問

「Toolbar とナビゲーション タイトル」レッスンは無料ですか?

はい。「Toolbar とナビゲーション タイトル」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、SwiftUI Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 SwiftUI Academyコースには全4レッスンが含まれています。

「Toolbar とナビゲーション タイトル」で何を学びますか?

バーにタイトルとツールバー ボタンを追加します。 ブラウザで直接実行するハンズオンコードでSwiftUI Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

SwiftUI Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのSwiftUI Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「Toolbar とナビゲーション タイトル」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このSwiftUI Academyレッスンでコードを書いて実行できますか?

はい。すべてのSwiftUI Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. NavigationLink で画面を表示する
  2. 詳細ビューへのデータ受け渡し
  3. Toolbar とナビゲーション タイトル
  4. プログラムによるナビゲーション パス
← SwiftUI Academyに戻る