In a navigation controller, you automatically get the correct colour and position of a navigation bar as expected.
like this
In Swift:
The best way to overcome this in iOS 8.1 and Swift is by conforming to the new UIBarPositioningDelegate protocol.
You connect the delegate of your NavigationBar to your view controller and conform to that protocol and by calling the method:
func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
return UIBarPosition.TopAttached
}
You can remove the top gap in the view controller. You need to place the bar 20 points below the top edge.