swift 给导航添加item,实现界面的跳转

时间:2021-03-25 18:05:15

//给导航添加item

        var rightItem = UIBarButtonItem(title: "First", style: UIBarButtonItemStyle.Plain, target: self, action: "fisrtItem:")

        rightItem.title = "First"

        self.navigationItem.rightBarButtonItem = rightItem

点击事件

func fisrtItem(right:UIBarButtonItem)

    {

        var vc = ViewController2()

        

        self.navigationController?.pushViewController(vc, animated: true)

    }