Restore navigationBar background image after setting it to [UIImage new]

后端 未结 3 1993
Happy的楠姐
Happy的楠姐 2021-02-01 05:04

I needed a completely transparent navigation bar for the mapView so I did this:

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarM         


        
3条回答
  •  借酒劲吻你
    2021-02-01 05:50

    For Swift 3:

    override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
    
      self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
      self.navigationController?.navigationBar.shadowImage = UIImage()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
      super.viewWillDisappear(animated)
    
      self.navigationController?.navigationBar.setBackgroundImage(nil, for: UIBarMetrics.default)
      self.navigationController?.navigationBar.shadowImage = nil
    }
    

提交回复
热议问题