Skip to content

Instantly share code, notes, and snippets.

@DisappearPing
Created May 31, 2017 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DisappearPing/e51fcfc1cef7f9ce51bda4db86e5f57e to your computer and use it in GitHub Desktop.
Save DisappearPing/e51fcfc1cef7f9ce51bda4db86e5f57e to your computer and use it in GitHub Desktop.
Conform this protocol, you can just use setRedNavBar() to set red background and white tintColor navigationBar.
import UIKit
protocol RedBackNavProtocol {
func setRedNavBar()
}
extension RedBackNavProtocol where Self : UIViewController {
func setRedNavBar() {
self.navigationController?.navigationBar.barTintColor = UIColor.navigation_bar_red
self.navigationController?.navigationBar.tintColor = UIColor.white
self.navigationBar?.titleTextAttributes = [
NSForegroundColorAttributeName: UIColor.white
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment