navigation添加BarButtonItem

   

    //加左边按钮

    func setupLeftBarButtonItem(){


        self.leftBtn = TCBaseBarButtonItem.init(title: "left", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ListViewController.leftButton))

        self.navigationItem.leftBarButtonItem = self.leftBtn

    }

    

    func leftButton() {

        print("点击左边按钮")

    }

    

//    加右边按钮

    func setupRightBarButtonItem(){

    

        self.rightBtn = TCBaseBarButtonItem.init(title:"title", style: UIBarButtonItemStyle.Plain, target: self, action:#selector(ListViewController.rightBarButtonItemClicked))

        self.navigationItem.rightBarButtonItem = self.rightBtn

    }

 

    func rightBarButtonItemClicked(){

    

        print("rightBarButtonItemClicked()")

    }

你可能感兴趣的:(ios)