一.创建导航

    let VC=ViewController()
    let navigationC = UINavigationController(rootViewController: VC)
    self.window?.rootViewController=navigationC
    self.window?.backgroundColor=UIColor.white

二.导航栏标题颜色

      self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white];  

三.导航条颜色

    self.navigationController?.navigationBar.barTintColor = UIColor.white;

四.设置导航左右点击按钮

    右:       

        let rightButton = UIButton(type: UIButtonType.custom)
        rightButton.frame = CGRect(x: 0, y: 0, width: 33, height: 32)
        rightButton.addTarget(self,action:#selector(ViewController.buttonAtion),for:UIControlEvents.touchUpInside)
        rightButton.setTitle("123", for: UIControlState.normal)
        let rightItem = UIBarButtonItem(customView: rightButton)
        self.navigationItem.rightBarButtonItem = rightItem

      点击事件:

          @objc func buttonAtion(button:UIButton){
          print("22按钮点击了")
      }

posted on 2018-02-27 10:53  代码少年_夕阳  阅读(154)  评论(0编辑  收藏  举报