UINavigationController 侧滑手势实现
import UIKit
class HPNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
let navBar = UINavigationBar.appearance()
navBar.barTintColor = UIColor.white
navBar.tintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.7)
navBar.titleTextAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17)]
self.initGlobalPan()
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
if viewControllers.count > 0 {
viewController.hidesBottomBarWhenPushed = true
viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back"), style: .plain, target: self, action: #selector(navigationBack))
}
.pushViewController(viewController, animated: )
}
() {
popViewController(animated: )
}
() -> {
target interactivePopGestureRecognizer.delegate
globalPan (target: target, action: (()))
globalPan.delegate .delegate ?
.view.addGestureRecognizer(globalPan)
navigationController.interactivePopGestureRecognizer.isEnabled
}
( : ) -> {
.childViewControllers.count
}
}