//HSHomeViewController *home = [[HSHomeViewController alloc]init];
//[self addChildController:home title:@"首页" imageName:@"home_tab" selectedImageName:@"home_tab_sel" navVc:[UINavigationController class]];
//HSFinancialViewController *financial =[[HSFinancialViewController alloc]init];
//[self addChildController:financial title:@"理财" imageName:@"理财_tab" selectedImageName:@"理财_tab_sel" navVc:[UINavigationController class]];
//HSNewsViewController *new = [[HSNewsViewController alloc]init];
//[self addChildController:new title:@"理财" imageName:@"理财_tab" selectedImageName:@"理财_tab_sel" navVc:[UINavigationController class]];
//[[UITabBar appearance] setBackgroundImage:[self imageWithColor:[UIColor whiteColor]]];
////设置tabbar
//[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
////设置自定义的tabbar
- (void)addChildController:(UIViewController*)childController title:(NSString*)title imageName:(NSString*)imageName selectedImageName:(NSString*)selectedImageName navVc:(Class)navVc
{
childController.title= title;
childController.tabBarItem.image= [[UIImageimageNamed:imageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
childController.tabBarItem.selectedImage= [[UIImageimageNamed:selectedImageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//设置一下选中tabbar文字颜色
[childController.tabBarItemsetTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColordarkGrayColor]}forState:UIControlStateSelected];
UINavigationController* nav = [[navVcalloc]initWithRootViewController:childController];
[selfaddChildViewController:nav];
}
- (UIImage*)imageWithColor:(UIColor*)color{
//一个像素
CGRectrect =CGRectMake(0,0,1,1);
//开启上下文
UIGraphicsBeginImageContextWithOptions(rect.size,NO,0);
[colorsetFill];
UIRectFill(rect);
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
//[self setCustomtabbar];
网友评论