Koinu
是一个自定义 UINavigationController
框架,通过为每一个 UIViewController
维护单独的 UINavigationController
从而使开发者便捷的设置 NavigationBar
视觉样式。
VMNavigationController
┌─VMContainerViewController
│ ──VMContainerNavigationController
│ ──firstViewController
│
└─VMContainerViewController
──VMContainerNavigationController
──secondViewController
/// 获取得到的是 `VMContainerNavigationController`
self.navigationController
/// 获取得到的是 `VMNavigationController`
self.vm.navigationController
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let viewController: UIViewController = ...
let rootNavigationController = VMNavigationController(rootViewController: viewController)
self.window.rootViewController = rootNavigationController
return true
}
/// 禁用侧滑返回
self.vm.disableInteractivePop = true
/// 通过重写 `navigationBarClass` 实现自定义 `UINavigationBar`
override var navigationBarClass: AnyClass? {
return CustomNavigationBar.self
}
/// 使用系统样式的 `backBarButtonItem`
self.vm.navigationController.vm.useSystemBackBarButtonItem = true
/// 使用根视图的 `navigationBar` 属性
self.vm.navigationController.vm.useRootNavigationBarAttributes = true
VMNavigationController
──VMContainerViewController
──VMContainerNavigationController
──UITabBarController
┌─VMContainerViewController
│ ──firstViewController
│
├─VMContainerViewController
│ ──secondViewController
│
├─VMContainerViewController
│ ──thirdViewController
│
└─VMContainerViewController
──fourthViewController
let tabBarController = UITabBarController()
if #available(iOS 13.0, *) {
tabBarController.tabBar.standardAppearance = appearance
}
if #available(iOS 15.0, *) {
tabBarController.tabBar.scrollEdgeAppearance = appearance
}
let firstViewController = UIViewController()
firstViewController.tabBarItem = UITabBarItem(title: "First", image: UIImage ..., selectedImage: UIImage ...)
let secondViewController = UIViewController()
secondViewController.tabBarItem = UITabBarItem(title: "Second", image: UIImage ..., selectedImage: UIImage ...)
let thirdViewController = UIViewController()
thirdViewController.tabBarItem = UITabBarItem(title: "Third", image: UIImage ..., selectedImage: UIImage ...)
let fourthViewController = UIViewController()
fourthViewController.tabBarItem = UITabBarItem(title: "Fourth", image: UIImage ..., selectedImage: UIImage ...)
tabBarController.viewControllers = [
VMContainerNavigationController(rootViewController: firstViewController),
VMContainerNavigationController(rootViewController: secondViewController),
VMContainerNavigationController(rootViewController: thirdViewController),
VMContainerNavigationController(rootViewController: fourthViewController)
]
let navigationController = VMNavigationController(noWrappingRootViewController: tabBarController)
self.window.rootViewController = rootNavigationController
──UITabBarController
┌─VMNavigationController
│ -─VMContainerViewController
│ ──VMContainerNavigationController
│ ──firstViewController
|─VMNavigationController
│ -─VMContainerViewController
│ ──VMContainerNavigationController
│ ──secondViewController
|─VMNavigationController
│ -─VMContainerViewController
│ ──VMContainerNavigationController
│ ──thirdViewController
└─VMNavigationController
-─VMContainerViewController
──VMContainerNavigationController
──fourthViewController
let tabBarController = UITabBarController()
if #available(iOS 13.0, *) {
tabBarController.tabBar.standardAppearance = appearance
}
if #available(iOS 15.0, *) {
tabBarController.tabBar.scrollEdgeAppearance = appearance
}
let firstViewController = UIViewController()
firstViewController.tabBarItem = UITabBarItem(title: "First", image: UIImage ..., selectedImage: UIImage ...)
let secondViewController = UIViewController()
secondViewController.tabBarItem = UITabBarItem(title: "Second", image: UIImage ..., selectedImage: UIImage ...)
let thirdViewController = UIViewController()
thirdViewController.tabBarItem = UITabBarItem(title: "Third", image: UIImage ..., selectedImage: UIImage ...)
let fourthViewController = UIViewController()
fourthViewController.tabBarItem = UITabBarItem(title: "Fourth", image: UIImage ..., selectedImage: UIImage ...)
tabBarController.viewControllers = [
VMNavigationController(rootViewController: firstViewController),
VMNavigationController(rootViewController: secondViewController),
VMNavigationController(rootViewController: thirdViewController),
VMNavigationController(rootViewController: fourthViewController)
]
self.window.rootViewController = tabBarController
https://github.com/spirit-jsb/Koinu.git
spirit-jsb, [email protected]
Koinu
可在 MIT
许可下使用,更多详情请参阅许可文件。
link |
Stars: 1 |
Last commit: 3 weeks ago |
publish version 1.0.7
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics