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];

 

上一篇:关于IOS UIlable 一行未满就换行


下一篇:内存管理(二)物理内存分配以及slab分配器(读奔跑吧linux内核总结)