设置TabbarController
(1)在appdelegate里新建一个TabbarController并设置赋值
//首页
GJGHomeController*homeController=[[GJGHomeControlleralloc]init];
BaseNavigationController*homeNavi=[[BaseNavigationControlleralloc]initWithRootViewController:homeController];
homeNavi.title=@"首页";
homeNavi.tabBarItem.image=[UIImageimageNamed:@"Home_default"];
//商圈
GJGBusinessAreaController*bussinessAreaController=[[GJGBusinessAreaControlleralloc]init];
BaseNavigationController*bussinessAreaNavi=[[BaseNavigationControlleralloc]initWithRootViewController:bussinessAreaController];
bussinessAreaNavi.title=@"商圈";
bussinessAreaNavi.tabBarItem.image=[UIImageimageNamed:@"Business circle_default"];
//发现
GJGFindController*findController=[[GJGFindControlleralloc]init];
BaseNavigationController*findNavi=[[BaseNavigationControlleralloc]initWithRootViewController:findController];
findNavi.title=@"发现";
findNavi.tabBarItem.image=[UIImageimageNamed:@"found_default"];
//我的
GJGMyController*myController=[[GJGMyControlleralloc]init];
BaseNavigationController*myNavi=[[BaseNavigationControlleralloc]initWithRootViewController:myController];
myNavi.title=@"我的";
myNavi.tabBarItem.image=[UIImageimageNamed:@"My_default"];
_tabBarController=[[BaseTabBarControlleralloc]init];
_tabBarController.delegate=self;
_tabBarController.viewControllers=@[homeNavi,bussinessAreaNavi,findNavi,myNavi];
(2).设置TabbarController背景色
UIView*backView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,ScreenWidth,49)];
backView.backgroundColor=[UIColorblackColor];
[self.tabBarController.tabBar insertSubview:backView atIndex:0];
self.tabBarController.tabBar.opaque=YES;
(3).设置TabbarItem文字颜色
_tabBarController.tabBar.tintColor=[UIColorwhiteColor];