美文网首页
UINavigationController

UINavigationController

作者: 79d12e22ec53 | 来源:发表于2019-04-24 18:01 被阅读0次

UINavigationController

import UIKit

class FirstViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title = "first"
        self.view.backgroundColor = UIColor.lightGray
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "next", style: .plain, target: self, action: #selector(FirstViewController.nextPage))

    }

  //导航栏样式修改
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationItem.prompt = "正在载入"
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(FirstViewController.refresh))
        self.navigationController?.navigationBar.isTranslucent = false
        self.navigationController?.navigationBar.barStyle = UIBarStyle.black
        self.navigationController?.navigationBar.tintColor = UIColor.orange
    }
    
    @objc func nextPage() {
        let viewController = SecondViewController()
        self.navigationController?.pushViewController(viewController, animated: true)
    }
    
    @objc func refresh() {
        print("已刷新")
    }
  
  
  class SecondViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "second"
        self.view.backgroundColor = UIColor.white
    }
    
//    override func viewWillAppear(_ animated: Bool) {
//        super.viewWillAppear(animated)
    //导航栏隐藏
//        self.navigationController?.setToolbarHidden(false, animated: false)
//                self.navigationController?.setNavigationBarHidden(true, animated: true)
//    }
    

}

相关文章

网友评论

      本文标题:UINavigationController

      本文链接:https://www.haomeiwen.com/subject/mfhngqtx.html