我使用的UITabBarController有四個視圖控制器。這些是Dashboard,ComposeMessage,PostMessage和Profile。我想在tabBarItem中使用圖像。但問題是圖像沒有在UITabBar中顯示。UITabBarController圖像沒有顯示
UITabBarController *customBar = [[UITabBarController alloc] init];
DashboardViewController *social = [[DashboardViewController alloc]init];
social.tabBarItem.image = [UIImage imageNamed:@"prifile_tab.png"];
[customBar addChildViewController:social];
ComposeMessageViewController *composeMessage = [[ComposeMessageViewController alloc]init];
composeMessage.tabBarItem.image = [UIImage imageNamed:@"timer_post_tab.png"];
[customBar addChildViewController:composeMessage];
PostMessageViewController *postMessage = [[PostMessageViewController alloc] init];
postMessage.tabBarItem.image = [UIImage imageNamed:@"timer_post_tab.png"];
[customBar addChildViewController:postMessage];
ProfileViewController *profile = [[ProfileViewController alloc] init];
profile.tabBarItem.image = [UIImage imageNamed:@"timer_post_tab.png"];
[customBar addChildViewController:profile];
NSArray *tabBarArray = @[social,composeMessage,postMessage,profile];
[customBar setViewControllers:tabBarArray];
self.window.rootViewController = customBar;
你的圖片alpha蒙版?如果不是,你應該設置圖像的渲染模式始終是原始的: 'UIImage * image = [[UIImage imageName:@「timer_post_tab.png」] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];' – beyowulf
感謝您的建議。有效。 –