iOS开发之UITabBar

来源:互联网 发布:单片机串口中断接收 编辑:程序博客网 时间:2024/06/06 01:46

//设置tabbar的背景图片

UITabBar *tabBar = self.tabBarController.tabBar;

//tabBar的字体颜色

[tabBarsetTintColor:[UIColor colorWithRed:0.0 green:176.0/255.0
blue:226.0/255.0 alpha:1.0];

//tabBar选中图片时字体颜色

tabBar.selectedImageTintColor = [UIColorclearColor];

UITabBarItem *item = [tabBar.items objectAtIndex:0];

#########################################################################################

FirstViewController *firstVC = [[[FirstViewControlleralloc] init] autorelease];

    firstVC.tabBarItem = [[[UITabBarItemalloc] initWithTitle:@""image:[UIImageimageNamed:@"iconfont-xiaosuolvetu-3.png"]selectedImage:[UIImageimageNamed:@"iconfont-xiaosuolvetu-4.png"]]autorelease];

    UINavigationController *firNaviVC = [[[UINavigationControlleralloc] initWithRootViewController:firstVC]autorelease];

    firstVC.title =@"";

    firstVC.navigationController.navigationBar.barTintColor = [UIColorcolorWithRed:0/255.0fgreen:191/255.0fblue:255/255.0falpha:1];

    

    SecondViewController *secondVC = [[[SecondViewControlleralloc] init] autorelease];

    secondVC.tabBarItem = [[[UITabBarItemalloc] initWithTitle:@""image:[UIImageimageNamed:@"iconfont-star.png"]selectedImage:[UIImageimageNamed:@"iconfont-star-2.png"]]autorelease];

    UINavigationController *secNaviVC = [[[UINavigationControlleralloc] initWithRootViewController:secondVC]autorelease];

    secondVC.title =@"";

    secondVC.navigationController.navigationBar.barTintColor = [UIColorcolorWithRed:0/255.0fgreen:191/255.0fblue:255/255.0falpha:1];

    

    ThirdViewController *thirdVC = [[[ThirdViewControlleralloc] init] autorelease];

    thirdVC.tabBarItem = [[[UITabBarItemalloc] initWithTitle:@""image:[UIImageimageNamed:@"iconfont-bbgzhinan.png"]selectedImage:[UIImageimageNamed:@"iconfont-bbgzhinan-2.png"]]autorelease];

    UINavigationController *thiNaviVC = [[[UINavigationControlleralloc] initWithRootViewController:thirdVC]autorelease];

    thirdVC.title =@"";

    thirdVC.navigationController.navigationBar.barTintColor = [UIColorcolorWithRed:0/255.0fgreen:191/255.0fblue:255/255.0falpha:1];

    

   NSArray *array = [NSArrayarrayWithObjects:firNaviVC, secNaviVC, thiNaviVC,nil];

    

    self.viewControllers = array;

    

    self.tabBar.tintColor = [UIColorcolorWithRed:0/255.0fgreen:191/255.0fblue:255/255.0falpha:1]


0 0
原创粉丝点击