Skip to content

Instantly share code, notes, and snippets.

@apple-avadhesh
Last active April 24, 2019 18:44
Show Gist options
  • Save apple-avadhesh/87d15f74fc2a69f5f2d3bafb28e5a652 to your computer and use it in GitHub Desktop.
Save apple-avadhesh/87d15f74fc2a69f5f2d3bafb28e5a652 to your computer and use it in GitHub Desktop.
CustomNavigation - Swift 4
class CustomNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
let appearance = UIBarButtonItem.appearance()
appearance.setBackButtonTitlePositionAdjustment(UIOffset.init(horizontal: -1000, vertical: 0), for: .default)
self.navigationBar.isTranslucent = true
self.navigationBar.barTintColor = UIColor.black
#if swift(>=4.0)
self.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16.0)]
#elseif swift(>=3.0)
self.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 16.0)];
#endif
self.navigationBar.tintColor = UIColor.white
self.navigationItem.title = "Example"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment