Skip to content

Instantly share code, notes, and snippets.

@DisappearPing
Created May 31, 2017 02:39
Show Gist options
  • Save DisappearPing/54a05c1890319d6abc492782ae46f701 to your computer and use it in GitHub Desktop.
Save DisappearPing/54a05c1890319d6abc492782ae46f701 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