2015-11-03 77 views
0

我在UITabBarController中工作,当我要为选项卡设置图像时,视图打开时图像不会第一次出现。我不知道如何解决这个问题。如何在uitabbaritem中设置默认图像

这是我使用的代码:

UIImage *prfimage = [UIImage imageNamed:@"profile_o.png"]; 
UIImage *selimage = [UIImage imageNamed:@"profile_o.png"]; 
UITabBarItem *tbP = [[UITabBarItem alloc] initWithTitle:@"" image:prfimage tag:YES]; 
[self setTabBarItem:tbP]; 
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:247/255.0f green:148/255.0f blue:29/255.0f alpha:2.0f]]; 
self.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); 
self.title = nil; 
+0

请参阅此链接设置选项卡图像。 http://stackoverflow.com/questions/33366425/how-to-change-the-tab-bar-image-color-for-selected-and-unselected/33366626#33366626 – VRAwesome

+0

感谢您的回复我完成了它。 –

回答

0

通过以下方式可以设置。

UITabBarItem *tabItem = controller.tabBarItem; 
tabItem.image = [[UIImage imageNamed:@"history"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
+0

感谢您的回复,但它不适合我。 –

+0

@SandeepChaudhary你可以写你的整个功能,所以我可以检查出来。 –