NavigationBarItems는 이제 Depreciated 됨.
기존에 사용하던 방식
NavigationView {
...
.navigationBarItems(
leading: # CODE,
trailing: # CODE
)
}
struct FlavorView: View {
var body: some View {
NavigationView {
List {
Text("Chocolate")
Text("Vanilla")
Text("Strawberry")
}
.navigationBarTitle(Text("Today‘s Flavors"))
.navigationBarItems(leading:
HStack {
Button("Hours") {
print("Hours tapped!")
}
}, trailing:
HStack {
Button("Favorites") {
print("Favorites tapped!")
}
Button("Specials") {
print("Specials tapped!")
}
}
)
}
}
}
하지만 공식 문서에 들어가면 Deprecated라고 되어있음!
즉, 더이상 사용하지 않는다는 것!
코드에 적용하면 적용이 되기는 하겠지만 추천드리지는 않습니다!
대신 공식문서에서 상단에 toolBar를 사용하라고 나와있습니다!
참고로 tabBarItems과 toolbar의 차이점은 기능면에서도 있지만,
tabBarItems는 macOS에서는 적용이되지 않지만 toolbar는 가능하다는 점에서 가장 큰 차이가 있습니다!