iOS 去除 TabBarItem的圖片預設顏色

weixin_34185560發表於2016-11-21

參考:https://my.oschina.net/u/2299977/blog/386251

//UITabBar設定未選中圖片
[yourTabBarItem setImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

//UITabBar設定選中圖片
[yourTabBarItem setSelectedImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
 //設定未選中字型顏色 
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0x003500), NSForegroundColorAttributeName, nil] 
    forState:UIControlStateNormal];
                                                       
   //設定選中字型顏色                                                    
    [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
    UIColorFromRGB(0xff3500), NSForegroundColorAttributeName, nil] 
    forState:UIControlStateSelected];

相關文章