Setting the tab bar icon color when popup is shown?

自闭症网瘾萝莉.ら 提交于 2020-01-04 03:44:07

问题


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:

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.


回答1:


self.tabBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

Does the job.



来源:https://stackoverflow.com/questions/25937079/setting-the-tab-bar-icon-color-when-popup-is-shown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!