Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the tab bar icon color when popup is shown?

I was already able to set the text and icon colors for my tab bar items as desired. White for not active, blue for active.

However, I still run into one issue: When a popover or alert view is shown, the tab bar item icon is greyed out:

enter image description hereenter image description here

Is there any possibility to keep the blue color for this state?

Thanks for your help.

EDIT

I'm sorry, but my question is not a duplicate. I already do all these things:

self.tabBar.tintColor = COLOR_CORPORATE_BLUE;
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                   [UIColor whiteColor], NSForegroundColorAttributeName,
                                                   nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                   COLOR_CORPORATE_BLUE, NSForegroundColorAttributeName,
                                                   nil] forState:UIControlStateSelected];

NSUInteger i = 0;
NSString *imageName = @"";
for (UITabBarItem *item in self.tabBar.items) {
    switch (i) {
        case 0: imageName = @"home_tab_db"; break;
        case 1: imageName = @"home_tab_al"; break;
        case 2: imageName = @"home_tab_ru"; break;
        case 3: imageName = @"home_tab_da"; break;
    }

    UIImage *img = [UIImage imageNamed:imageName];
    if ([img respondsToSelector:@selector(imageWithRenderingMode:)]) {
        item.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    } else {
        item.image = img;
    }
    item.selectedImage = [UIImage imageNamed:[imageName stringByAppendingString:@"_active"]];

    i++;
}

However, as I've written, any popover, alert view, etc. will change the color of my active icon to grey.

like image 983
Sebastian Greifeneder Avatar asked Sep 29 '22 20:09

Sebastian Greifeneder


1 Answers

self.tabBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

Does the job.

like image 75
Radek Wilczak Avatar answered Nov 15 '22 10:11

Radek Wilczak