2018-01-04

2018-05-04  本文已影响0人  Whatever永不放弃

import "ViewController.h"

import "OneViewController.h"

import "TwoViewController.h"

import "ThreeViewController.h"

import "FourViewController.h"

import "FiveViewController.h"

@interface ViewController ()
@property(nonatomic,strong)UITabBarController *tab;

@end

@implementation ViewController

}
-(UITabBarController *)tab{
if (!_tab) {
_tab = [[UITabBarController alloc]init];
// Do any additional setup after loading the view, typically from a nib.

OneViewController *oneVC = [[OneViewController alloc]init];
    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:oneVC];
    UITabBarItem *itm1 = [[UITabBarItem alloc]initWithTitle:@"推荐" image:[UIImage imageNamed:@"menu_recom_normal@3x.png"] tag:0];
    
    oneVC.title = @"推荐";


TwoViewController *twoVC = [TwoViewController new];
    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:twoVC];
    UITabBarItem *itm2 = [[UITabBarItem alloc]initWithTitle:@"同城" image:[UIImage imageNamed:@"menu_near_normal@3x.png"] tag:1];
    
    twoVC.title = @"同城";


ThreeViewController *threeVC = [ThreeViewController new];
    UINavigationController *nav3  = [[UINavigationController alloc]initWithRootViewController:threeVC];
    UITabBarItem *itm3 = [[UITabBarItem alloc]initWithTitle:@"互动" image:[UIImage imageNamed:@"menu_mes_normal@3x.png"]tag:2];
    threeVC.title = @"互动";


FourViewController *fourVC = [FourViewController new];
    UINavigationController *nav4  = [[UINavigationController alloc]initWithRootViewController:fourVC];
    UITabBarItem *itm4 = [[UITabBarItem alloc]initWithTitle:@"消息" image:[UIImage imageNamed:@"menu_mine_normal@3x.png"]tag:3];
    fourVC.title = @"消息";
    
    
    FiveViewController *fiveVC = [FiveViewController new];
    UINavigationController *nav5  = [[UINavigationController alloc]initWithRootViewController:fiveVC];
    UITabBarItem *itm5 = [[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"menu_mine_normal@3x.png"]tag:4];

// fiveVC.title = @"我的";

    nav1.tabBarItem = itm1;
    nav2.tabBarItem = itm2;
    nav3.tabBarItem = itm3;
    nav4.tabBarItem = itm4;
    nav5.tabBarItem = itm5;
    
    self.viewControllers = @[nav1,nav2,nav3,nav4,nav5];
    
    
    
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];








}
return _tab;

}

@end

上一篇 下一篇

猜你喜欢

热点阅读