• 네비게이션은 다른 스크린과 뷰 사이를 이동하고 탐색할 수 있게 해줌
  • UINavigationController와 마찬가지로 navigationStack을 관리하며 NavigationBar 를 제공하여 화면간 이동을 지원
  • NavigationView는 iOS 기준 13.0 ~ 17.0 사용가능하며 deprecated 예정이기 때문에 iOS 16.0 부터 지원하는 프로젝트라면 NavigationStack을 사용

 

  • NavigationStack, NavigationSplitView 뿐만 아니라 NavigationView에서도 사용 가능
struct NavigationLink<Label, Destination> where Label : View, Destination : View
  • label은 현재 화면에 보이는 뷰로서 NavigationView 영역에 표시됨. label 컨테이너로 전달된 View를 누르면 destination 뷰로 navigationing 함
  • destination은 네비게이션(화면이동) 후 나타나는 화면
                NavigationLink("test2") {
                    Text("label2")
                }

 

Modifier

.navigationBarTitle("navigation title", displayMode: .large)

navigation bar title 지정

 

.navigationBarItems(
                leading: NavigationLink(destination: { Text("더보기 메뉴") }, label: { Text("더보기") }) ,
                trailing: Button("다음") { print("다음 클릭됨") })

네비게이션바에 View를 넣을 수 있음

 

 

 

참고 사이트

 

NavigationView | Apple Developer Documentation

A view for presenting a stack of views that represents a visible path in a navigation hierarchy.

developer.apple.com

 

 

NavigationView in SwiftUI · Mahi Garg

Navigation involves moving between different screens or views within an app. SwiftUI provides a navigation view hierarchy that allows users to navigate between different views seamlessly. The NavigationView is the container view that manages the navigation

mahigarg.github.io

 

NavigationLink | Apple Developer Documentation

A view that controls a navigation presentation.

developer.apple.com