A clean and easy-to-use navigation in SwiftUI base on UINavigationController in UIKit
VNavigator
VNavigator
is a clean and easy-to-use navigation in SwiftUI base on UINavigationController in UIKit
Installation
From CocoaPods
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like VNavigator
in your projects. First, add the following line to your Podfile:
pod 'VNavigator'
Usage
- Wrap your ContentView with a
NavigationView
- In ContentView implement
AppNavigator
struct ContentView: AppNavigator {
var body: some View {
Button(action: {
navigator.pushToView(view: DetailScreen1())
}, label: {
Text("Next to Detail Screen")
})
}
}
- Use with
Environment
struct ContentView: View {
@Environment (\.navigator) var navigator
var body: some View {
Button(action: {
navigator.pushToView(view: DetailScreen1())
}, label: {
Text("Next to Detail Screen")
})
}
}
Function support like you use with UIKit
- Support push
navigator.pushToView(view: DetailScreen())
- Support pop
navigator.pop()
- Support pop to root
navigator.popToRootView()
- Support pop to specific view
navigator.popToView(DetailScreen.self)
- Support present with UIKit animation
navigator.present(DetailScreen()))
- Support dismiss
navigator.dismiss()
Requirements
- Xcode 12+
- iOS 13+
- Swift 5.0+