A title for this view to display in the navigation bar. ナビゲーションバーにおいて表示する、このビューに対するタイトル。
Instance Method
インスタンスメソッド
navigation
navigationBarTitle(_:)
Sets the title of this view’s navigation bar with a string.
このビューのもつナビゲーションバーのタイトルをある文字列で設定します。
Availability 有効性
- iOS 13.0–15.4 Deprecated
- iPadOS 13.0–15.4 Deprecated
- Mac Catalyst 13.0–15.4 Deprecated
- tvOS 13.0+
- watchOS 6.0–8.5 Deprecated
Technology
- Swift
UI
Declaration 宣言
func navigationBarTitle<S>(_ title: S) -> some View
where S : StringProtocol
Parameters パラメータ
title
Discussion 議論
Use navigation
to set the title of the navigation bar using a String
. This modifier only takes effect when this view is inside of and visible within a Navigation
.
In the example below, text for the navigation bar title is provided using a string:
struct FlavorView: View {
let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
"Pistachio"]
let text = "Today's Flavors"
var body: some View {
NavigationView {
List(items, id: \.self) {
Text($0)
}
.navigationBarTitle(text)
}
}
}