2016-09-04 183 views
0

我使用的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; 
+0

你的圖片alpha蒙版?如果不是,你應該設置圖像的渲染模式始終是原始的: 'UIImage * image = [[UIImage imageName:@「timer_post_tab.png」] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];' – beyowulf

+0

感謝您的建議。有效。 –

回答

1

只是檢查烏爾圖像尺寸是否合適..u應該給唯一有效大小的圖像,也沒有隨機大小

2

的TabBar的大小應該是這樣的

@ 1X尺寸25×25(最大:48×32)

@ 2倍尺寸50×50(最大:96×64)

@ 3×:尺寸75×75(最大:144×96)

+0

是的,我得到了。謝謝.. –