// // CustomNaviBar.swift // VoicePractice // // Created by Wei Xian Ong on 2020/7/3. // Copyright © 2020 Wei Xian Ong. All rights reserved. // import UIKit class CustomNaviBar: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.navigationItem.hidesBackButton = true let rightBtn = UIButton.init(frame: CGRect(x: 0, y: 0, width: 23, height: 22)) rightBtn.setBackgroundImage(UIImage.init(named: "hamburger_button"), for: UIControl.State()) rightBtn.addTarget(self, action: #selector(self.navRightBtnAction), for: UIControl.Event.touchUpInside) self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: rightBtn) // Do any additional setup after loading the view. } @objc func navRightBtnAction(){ self.navigationController?.popToRootViewController(animated: true) } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }