Transparent UINavigationBar in Swift

后端 未结 6 980
感动是毒
感动是毒 2020-12-13 06:43

I am trying to make my UINavigationBar in UINavigationController transparent. I created a subclass of UINavigationController and liked

6条回答
  •  感动是毒
    2020-12-13 07:11

    If you're using Swift 2.0 uses the code block below:

     self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
     self.navigationController?.navigationBar.shadowImage = UIImage()
     self.navigationController?.navigationBar.translucent = true
    

    For Swift 3.0 use:

    navigationController?.setNavigationBarHidden(false, animated: true)
    navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
    navigationController?.navigationBar.shadowImage = UIImage()
    navigationController?.navigationBar.isTranslucent = true
    

提交回复
热议问题