我正在使用UITabbarview控制器,我使用以下代码设置了一个图像,但是第一次打开视图时它是不可见的。
UIImage *prfimage = [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 :(得分:0)
你应该使用这段代码来设置 ViewController
中的UIImage
[[[[self.tabBarController tabBar] items] objectAtIndex:0] setImage:[[UIImage imageNamed:@"yourImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]] ;//objectAtIndex:0 mean your first TabBar item You can do it for multiple.
这会有所帮助。谢谢