RDVTabBarController的使用介绍

import "RDVTabBarItem.h"

#import "RDVViewController.h"
#import "ViewController.h"
#import "RDVTabBarItem.h"

@interface RDVViewController ()

@end

@implementation RDVViewController

- (void)viewDidLoad {
     [super viewDidLoad];
     
     ViewController *homeView=[[ViewController alloc]init];
     UINavigationController *NAV1 = [[UINavigationController alloc] initWithRootViewController:homeView];
     
     ViewController *View=[[ViewController alloc]init];
     UINavigationController *NAV2 = [[UINavigationController alloc] initWithRootViewController:View];
     
     ViewController *home=[[ViewController alloc]init];
    UINavigationController *NAV3 = [[UINavigationController alloc] initWithRootViewController:home];
     
     self.viewControllers = @[NAV1,NAV2,NAV3];
     [self customizeTabBarForController:self];

 }
 
 - (void)customizeTabBarForController:(RDVTabBarController *)tabBarController {
    
     NSArray *tabBarItemImages = @[@"首页select", @"首页select",@"首页select"];
     
     NSInteger index = 0;
     for (RDVTabBarItem *tabberItem in [[tabBarController tabBar] items]) {
         
         tabberItem.title = [NSString stringWithFormat:@"%ld",index+1];
         
         NSDictionary *tabBarTitleUnselectedDic = @{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:15]};
        NSDictionary *tabBarTitleSelectedDic = @{NSForegroundColorAttributeName:[UIColor blueColor],NSFontAttributeName:[UIFont systemFontOfSize:15]};
         //修改tabberItem的title颜色
         tabberItem.selectedTitleAttributes = tabBarTitleSelectedDic;
         tabberItem.unselectedTitleAttributes = tabBarTitleUnselectedDic;

         UIImage *selectedimage = [UIImage imageNamed:@"首页"];
         UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",
                                                         [tabBarItemImages objectAtIndex:index]]];
         //设置tabberItem的选中和未选中图片
         [tabberItem setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
        
         index++;
     }
 }

下载地址:https://github.com/robbdimitrov/RDVTabBarController

AppDelegate里面的不多说

例如

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     
RDVViewController *rootViewController = [[RDVViewController alloc] init];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];

猜你喜欢

转载自blog.csdn.net/C_philadd/article/details/88657302