我在UITabBarController
工作,当我要为标签设置图像时,图像在视图打开时不会首次出现。我不知道如何解决这个问题。
这是我正在使用的代码:
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 :(得分:0)
按照以下方式设置。
UITabBarItem *tabItem = controller.tabBarItem;
tabItem.image = [[UIImage imageNamed:@"history"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];