Topic:
- NavigationTitle ๋ฃ๊ธฐ
- NavigationItem ์ค์

SwiftUI ๋ธ๋ก๊ทธ๊ธ๋ค์ ์ฐธ๊ณ ํ๊ธฐ๊ฐ ๊ฐ๋ ์ ๋งคํ๋ค๊ณ ๋๊ปด์ง ๋๊ฐ ์๋๋ฐ, ์๋ฌด๋๋ ์ ํ์ด ๊ณ์ ๊ฐ์ ํ๊ณ ์๋ ์ค์ด๋ผ ๊ณผ๊ฑฐ(๋ผ๊ธฐ์ ๋น๊ต์ ์ต๊ทผ์ด์ง๋ง)์ ์ฐ์ฌ์ง ๊ธฐ์ ๋ค ์ค Deprecated ๋ ๊ฒ ๋ง๋ค๋ ์ ๊ฐ๋ค.
์ค์ ๋ก NavigationView๋ฅผ ์ฌ์ฉํด์ navigationTitle์ ๋จ ๋ธ๋ก๊ทธ ๊ธ๋ค์ด ๋ง์๋๋ฐ, ํ์ฌ๋ Deprecated ๋์๋ค. ๊ทธ๋์ ์ฌ์ฉํ ์ ์๋ ๊ฒ NavigationStack์ด๋ค.

๋ค๋ฅธ ์คํ๋ค ์ฌ์ฉํ๋ ๊ฒ์ฒ๋ผ NavigationStack์ด ๋๋๋ ์ค๊ดํธ ๋์.navigationTitle("Title Text")๋ฅผ ๋ถ์ฌ์ฃผ๋ฉด ๋ค๋น๊ฒ์ด์ ํ์ดํ์ด ๋์ค๊ฒ ๋๋ค. ์ด๋, navigationBarTitleDisplayMode ์ ํตํด ํ์ดํ์ ์คํ์ผ์ ์กฐ์ ํด์ค ์ ์๋ค.

์ต์ ์ผ๋ก automatic, inline, large ์ธ ๊ฐ๊ฐ ์๋ค. ๊ฐ์ฅ ์ต์ํ ํํ์ ๋ค๋น๊ฒ์ด์ ํ์ดํ์ ์ฌ์ฉํ๋ ค๋ฉด Inline์ผ๋ก ์ค์ ํ๋ฉด ๋๋ค!
1. automatic

2. inline

3. large

(automatic๊ณผ large๋ ํฐ ์ฐจ์ด๊ฐ ์์ด๋ณด์ธ๋ค,,,,)
๋ด๊ฐ ์์ฑํ ์ค์ ๋ทฐ ์ฝ๋:
- ๋ค๋น๊ฒ์ด์ ์คํ ์ฌ์ฉ
- ๋ค๋น๊ฒ์ด์ ํ์ดํ ์กด์ฌ
- ํด๋ฐ ์์ดํ ์กด์ฌ
struct SettingView: View {
var body: some View {
NavigationStack {
VStack {
Text("ํธ์ ์๋ฆผ")
.font(.system(size: 18, weight: .bold))
.position(x: 50, y: 20)
.frame(height: 30)
//์ธํ
๋ฆฌ์คํธ
SettingListView()
Spacer()
}
//๋ค๋น๊ฒ์ด์
๋ฐ ์ค์
.navigationTitle("์ค์ ") //ํ์ดํ
.navigationBarTitleDisplayMode(.inline) //์คํ์ผ
.toolbar{
ToolbarItemGroup(placement: .topBarLeading) {
Button(action: {
print("๋ค๋ก๊ฐ๊ธฐ ํด๋ฆญ")
}, label: {
Image(systemName: "chevron.backward")
.foregroundStyle(.black)
})
}
ToolbarItemGroup(placement: .topBarTrailing) {
Button(action: {
print("ํ ํด๋ฆญ")
}, label: {
Image(systemName: "house.fill")
.foregroundStyle(.black)
})
}
} // ** ํด๋ฐ
}
}
}
https://developer.apple.com/documentation/swiftui/view/navigationbartitledisplaymode(_:)
navigationBarTitleDisplayMode(_:) | Apple Developer Documentation
Configures the title display mode for this view.
developer.apple.com
https://developer.apple.com/documentation/swiftui/navigationview
NavigationView | Apple Developer Documentation
A view for presenting a stack of views that represents a visible path in a navigation hierarchy.
developer.apple.com
https://developer.apple.com/documentation/swiftui/navigationstack
NavigationStack | Apple Developer Documentation
A view that displays a root view and enables you to present additional views over the root view.
developer.apple.com
'๐ Dev > SwiftUI' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SwiftUI] Property Wrapper ์ด์ ๋ฆฌ (0) | 2024.07.26 |
---|---|
[SwiftUI] Frame (0) | 2024.07.22 |
[SwiftUI] @State (0) | 2024.05.22 |
[SwiftUI] Info.plist (0) | 2023.11.20 |
[SwiftUI] VStack vs LazyVStack (5) | 2023.11.06 |