隐藏导航条 -- 侧滑照样使用的骚操作
import UIKit
class TempViewController: UIViewController, UIGestureRecognizerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.orange
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 隐藏导航栏的操作 (如果单独写这个的话,侧滑返回就会失去作用)
navigationController?.setNavigationBarHidden(true, animated: true)
// 保证侧滑返回可以使用(设置代理 -> 设置可用)
navigationController?.interactivePopGestureRecognizer?.delegate = self
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewWillDisappear(_ animated: Bool) {
// super.viewWillAppear(animated)
// 显示导航栏的操作
navigationController?.setNavigationBarHidden(false, animated: true)
}
}
网友评论