2015-08-22 117 views
0

我正在嘗試創建一個像Instagram一樣的UITabBar。這看起來很不尋常,因爲選定的項目和中間項目具有佔據整個單元的背景顏色。我需要創建一個自定義UITabBar還是我可以提供圖像到內置的UITabBarController來複制這個?自定義UITabbar ios

enter image description here

回答

0

您可以構建的UITabBarController的子類,然後把這些代碼在viewWillAppear中。

- (void)viewWillAppear:(BOOL)animated{ 

for (NSInteger i = 1; i<= 5 ; i ++) { 
    UIViewController *VC = self.viewControllers[i-1]; 

    UIImage *image = [[UIImage imageNamed:[NSString stringWithFormat:@"TabBar%d",i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];; 
    UIImage *selImage = [[UIImage imageNamed:[NSString stringWithFormat:@"TabBar%dSel",i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
    UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:nil image:image selectedImage:selImage]; 
    item.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); 
    VC.tabBarItem = item; 
    item.tag = i-1; 

} 
0

我想你應該試試3.party M13InfiniteTabBar

它可以幫助您節省時間。你只是自定義的基礎上。