[英]How to set image on UITabbaritem?
我在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;
您應該使用這種和平的代碼在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.
會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.