2014-09-29 80 views
3

我試圖從更多菜單中的圖標更改藍色。我嘗試了幾乎所有我在StackOverflow上找到的東西,但在iOS 8上沒有任何工作。 我試過這個solution,但不起作用。 我發現改變顏色的唯一選擇是更改iOS8中更多菜單的UITabbar色調顏色

[[UIView appearance] setTintColor:[UIColor redColor]]; 

,但它改變了應用程序的所有顏色。

tint color not changed tint colour changed using UIView appearance tint color

的代碼只是故事板的新的項目,所以我只是說在故事板視圖。 感謝您的幫助。

編輯:後我加入了代碼

UIImage *myImage = [[UIImage imageNamed:@"music.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"New Title" image:myImage selectedImage:[UIImage imageNamed:@"music.png"]]; 

選擇視圖時的圖像被改變,但它仍然是藍色。

回答

7

要做你需要的,你應該通過爲每個控制器創建UITabBarItem並添加一個圖像和一個選定的圖像來使用圖像。

Apple Documentation about UITabBarItem

否則看起來在這裏,從@Aaron Brager:seing的完整代碼 先有後

編輯是很多錯誤在你的項目中,資產應該在xcassets文件夾,鑑於didload寫後您的代碼「超級viewDidLoad中]」等

關於您的問題,在你的viewDidLoad方法在FirstViewController

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    // Your code start here, not before the super 
    [[UITabBar appearance] setTintColor:[UIColor redColor]]; 

    // Get table view of more new viewController 
    UITableView *view =(UITableView*)self.tabBarController.moreNavigationController.topViewController.view; 

    view.tintColor = [UIColor redColor]; // Change the image color 

    if ([[view subviews] count]) { 
     for (UITableViewCell *cell in [view visibleCells]) { 
      cell.textLabel.textColor = [UIColor redColor]; // Change the text color 

     } 
    } 
} 
+0

感謝您的答覆,我試過代碼從建議,但仍然無法正常工作。我想我做錯了什麼。如果你能看一看,我附上完整的代碼。 – varu 2014-09-29 19:56:40

+0

@varu我剛剛更新了我的答案。我不明白你在使用Storyboard! – Ludovic 2014-09-29 20:45:33

+0

我在2010年開始的一個更大的項目中使用了色調顏色,並且必須使用圖標修復問題。我爲StackOverflow創建了一個新項目。 非常感謝你幫助我。我非常感謝你的幫助。我還有很多要學習:) – varu 2014-09-30 06:04:30