【问题标题】:Setting the tab bar icon color when popup is shown?显示弹出窗口时设置标签栏图标颜色?
【发布时间】:2014-11-14 05:38:31
【问题描述】:

我已经能够根据需要为标签栏项目设置文本和图标颜色。白色为未激活,蓝色为激活。

但是,我仍然遇到一个问题: 当显示弹出框或警报视图时,标签栏项目图标显示为灰色:

有没有可能保持这种状态的蓝色?

感谢您的帮助。

编辑

对不起,我的问题不是重复的。我已经做了所有这些事情:

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++;
}

但是,正如我所写,任何弹出框、警报视图等都会将我的活动图标的颜色更改为灰色。

【问题讨论】:

    标签: ios objective-c ios7 xcode5


    【解决方案1】:
    self.tabBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
    

    完成这项工作。

    【讨论】:

      【解决方案2】:

      我通过设置图像属性解决了这个问题。从 Assets 文件夹中选择一个图像 -> 单击特定图像 -> 转到属性检查器 -> 将 Render As 属性设置为原始图像

      【讨论】:

        猜你喜欢
        • 2018-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多