Skip to content

Instantly share code, notes, and snippets.

@DisappearPing
Created May 31, 2017 02:41
Show Gist options
  • Save DisappearPing/889b79b240f1499de672ef73c2d0ef85 to your computer and use it in GitHub Desktop.
Save DisappearPing/889b79b240f1499de672ef73c2d0ef85 to your computer and use it in GitHub Desktop.
Conform this protocol can help to set navigationBar is tanslucent or not
protocol TransparentNavProtocol {
func setTransparentNav()
func resetTransparentNav()
}
extension TransparentNavProtocol where Self: UIViewController {
func setTransparentNav() {
self.navigationController?.navigationBar.subviews[0].alpha = 0
self.navigationController?.navigationBar.tintColor = UIColor.white
self.navigationController?.navigationBar.isTranslucent = true
}
func resetTransparentNav() {
self.navigationController?.navigationBar.subviews[0].alpha = 1
self.navigationController?.navigationBar.isTranslucent = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment