Skip to content

Instantly share code, notes, and snippets.

@NickAger
Last active February 13, 2016 12:31
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 NickAger/23d219c4f4e2816e6a0b to your computer and use it in GitHub Desktop.
Save NickAger/23d219c4f4e2816e6a0b to your computer and use it in GitHub Desktop.
Allow a navigation bar in a view controller to behave as though the view controller was wrapped in a navigation controller - i.e. the navigation bar colour matches the status bar colour
// MARK: UIBarPositioningDelegate
extension ViewController : UIBarPositioningDelegate {
// see iOS: setting statusbar color without using UINavigationController
// http://stackoverflow.com/questions/31103076/ios-setting-statusbar-color-without-using-uinavigationcontroller
// (delegate set in the storyboard)
// ensures the status bar colour is set to the same as the navigation bar background colour; matches
// the behaviour of wrapping the ViewController in a NavigationController.
func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
return .TopAttached
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment