工作生活

ios - push 隐藏navigationBar,侧滑手势一

2019-06-30  本文已影响0人  best_su

隐藏导航条 -- 侧滑照样使用的骚操作

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)
    }
}

上一篇 下一篇

猜你喜欢

热点阅读