Sapan Diwakar

Software developer

Follow me on Twitter Check out my code on GitHub View some of my designs on Dribbble Take a look at my Linked In profile

NavBar problem with MKMapView in iOS7

While developing an iOS application, I came across the use of MKMapView. The map view itself is pretty easy to integrate in the app. But it comes with a very annoying bug in iOS 7 when working with a custom color for navigation bar. On the device, any controller containing the MKMapView turns the navigation bar to black and it doesn't respond to change of tintColor or barTintColor anymore. Everything works fine on simulator which makes it that much more annoying. Its been discussed in length on several posts on apple forum, but there hasn't been any fix for it yet.

A possible work-around for this problem is to switch off the transparency in viewWillAppear and switch it back on in viewDidAppear.

- (void)viewWillAppear:(BOOL)animated
    self.navigationController.navigationBar.translucent = NO;

- (void)viewDidAppear:(BOOL)animated
    self.navigationController.navigationBar.translucent = YES;

But there is a little flick when the view appears and you have to do this for every controller. A much better (temporary) fix for the problem is to use a translucent image for the nav bar instead of using a tintColor. It does remove the blur effect from the bar, but its better than having the bar turn black, right. Here's how I did that

// Customize navigation bar.
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image_navbar"] forBarMetrics:UIBarMetricsDefault];
} else {
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image_navbar_44px"] forBarMetrics:UIBarMetricsDefault];