| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A UINavigationController-like container view controller for macOS.
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/hechen/CocoaNavigationController.git", from: "2.0.0")
]Or in Xcode: File → Add Package Dependencies → Enter the repository URL.
import CocoaNavigationController
// Create navigation controller with a root view controller
let rootVC = MyViewController()
let navController = CocoaNavigationController(rootViewController: rootVC)
// Set as window's content view controller
window.contentViewController = navControllerlet detailVC = DetailViewController()
navigationController?.push(detailVC, animated: true)// Pop one level
navigationController?.pop(animated: true)
// Pop to specific view controller
navigationController?.popToViewController(targetVC, animated: true)
// Pop to root
navigationController?.popToRootViewController(animated: true)// Replace entire stack
let newStack = [rootVC, vc1, vc2, vc3]
navigationController?.setViewControllers(newStack, animated: true)// From any view controller in the stack
class MyViewController: NSViewController {
func goBack() {
navigationController?.pop(animated: true)
}
}class MyClass: CocoaNavigationControllerDelegate {
func navigationController(_ navController: CocoaNavigationController,
willShow viewController: NSViewController,
animated: Bool) {
print("Will show: \(viewController)")
}
func navigationController(_ navController: CocoaNavigationController,
didShow viewController: NSViewController,
animated: Bool) {
print("Did show: \(viewController)")
}
}
navController.delegate = myDelegateThe navigation controller uses snapshot-based animations for smooth transitions:
Push →
┌─────────────┐ ┌─────────────┐
│ │ │ │
│ From │ │ To │
│ │ │ │
└─────────────┘ └─────────────┘
← Pop
This ensures smooth 60fps animations regardless of view complexity.
MIT License - see LICENSE for details.
Originally created by Chen He in 2019. Updated in 2026 with modern Swift patterns and Swift Package Manager support.
| Back | FazBrowse Home | New Git URL |