There is a little problem with UINavigationBar which I\'m trying to overcome. When you hide the status bar using prefersStatusBarHidden() method in
While this isn't a direct answer to your Swift question (seems like it may be a bug that load doesn't work for Swift extensions of NSObjects), however, I do have a solution to your original problem
I figured out that subclassing UINavigationBar and providing a similar implementation to the swizzled solution works in iOS 7 and 8:
class MyNavigationBar: UINavigationBar {
override func sizeThatFits(size: CGSize) -> CGSize {
if UIApplication.sharedApplication().statusBarHidden {
return CGSize(width: frame.size.width, height: 64)
} else {
return super.sizeThatFits(size)
}
}
}
Then update the class of the Navigation Bar in your storyboard, or use init(navigationBarClass: AnyClass!, toolbarClass: AnyClass!) when constructing your navigation controller to use the new class.