Search code examples
iosobjective-cappearance

Prior iOS 7 tintColor without navigationBar background


I'm setting:

[self.window setTintColor:[UIColor redColor]];

In iOS 7 everything works ok - my navigationController.navigationBar is white (as I set it transparent) and all icons are colored to red. However in iOS 6 (where navigation bar is set NOT to be transparent) all icons are left with its original colors (eg blue). I can't find a way to color these images in iOS 6, is it possible?

To be more precise:

if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_6_1) {
    [self.navigationBar setTintColor:[UIColor whiteColor]];
}

Now I get white navigation bar but also the titles and buttons are white - how to colour them?


Solution

  • Please go through the documentation(s) carefully.

    UIWindow inherits from UIVIew and the tintColor property of UIView is not available prior to iOS7. From the source itself (UIView):

    @property(nonatomic,retain) UIColor *tintColor NS_AVAILABLE_IOS(7_0);
    

    It clearly defines this. So you cannot set this prior to iOS7.

    You will have to set the navigationBar's tintColor (which became barTintColor in iOS7) to white. You might want to use the UIAppearance selector for changes to be reflected throughout your app.

    EDIT:

    All items in a UINavigationBar are UIBarButtonItems. You will have to set their own tintColors.