如何在tabbar图标之间添加分隔符

时间:2014-11-19 18:53:59

标签: objective-c ios8 uitabbarcontroller tabbar uitabbaritem

如何在TabBar的每个图标之间添加分隔线。

//TabbarViewController.h

    #import <UIKit/UIKit.h>
    @interface TabBarViewController : UITabBarController <UITabBarControllerDelegate>{ }
    @end

// TabbarViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];
    HomeViewController *HomeViewController = [[HomeViewController alloc] init];
    UploadViewController *UploadViewController = [[UploadViewController alloc] init];
    MapViewController *mapviewController = [[MapViewController alloc]init];
    FavouriteViewController *favouriteViewController = [[FavouriteViewController alloc]init];

    HomeViewController.title = @"Home";
    UploadViewController.title = @"Upload";
    mapviewController.title = @"Map";
    favouriteViewController.title = @"Favourite";

    UINavigationController *homeNavCont = [[UINavigationController alloc] initWithRootViewController:HomeViewController];
    UINavigationController *secondNavCont = [[UINavigationController alloc] initWithRootViewController:UploadViewController];
    UINavigationController *thirdNavCont = [[UINavigationController alloc] initWithRootViewController:mapviewController];
    UINavigationController *fourthNavCont = [[UINavigationController alloc] initWithRootViewController:favouriteViewController];

    [[homeNavCont   tabBarItem] setImage:[UIImage imageNamed:@“Home32”]];
    [[secondNavCont tabBarItem] setImage:[UIImage imageNamed:@"camera32"]];
    [[thirdNavCont  tabBarItem] setImage:[UIImage imageNamed:@"Navigation32"]];
    [[fourthNavCont tabBarItem] setImage:[UIImage imageNamed:@"Faviourte32"]];

    HomeViewController.tabBarItem.selectedImage = [[UIImage imageNamed:@"Home32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
        UploadViewController.tabBarItem.selectedImage = [[UIImage imageNamed:@"camera32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mapviewController.tabBarItem.selectedImage = [[UIImage imageNamed:@"Navigation32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    favouriteViewController.tabBarItem.selectedImage = [[UIImage imageNamed:@"Faviourte32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    self.viewControllers=[NSArray arrayWithObjects:homeNavCont,secondNavCont,thirdNavCont,fourthNavCont,nil];
    self.delegate = self;
    [self setSelectedIndex:0];
}

需要建议在tabbar的图标之间添加分隔符。

TabBar Seperator

0 个答案:

没有答案