2014-09-19 144 views
3

我已經能夠根據需要爲我的標籤欄項目設置文本和圖標顏色。白色表示未激活,藍色表示激活。顯示彈出窗口時設置標籤欄圖標顏色?

但是,我仍然會碰到一個問題: 當顯示酥料餅或警報視圖,標籤欄項目圖標是灰色的:

enter image description here enter image description here

是否有可能保持這種狀態的藍色?

感謝您的幫助。

編輯

我很抱歉,但我的問題是不是重複。我已經做這些事情:

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

然而,當我寫的,任何酥料餅,警報視圖等,將改變我的活動圖標爲灰色的顏色。

回答

0
self.tabBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; 

做這項工作。