Last active
February 13, 2016 12:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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