Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.