美文网首页
2018-04-16

2018-04-16

作者: Whatever永不放弃 | 来源:发表于2018-04-16 09:36 被阅读0次

tb

#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

- (void)viewDidLoad {
    [super viewDidLoad];
    [self tab];
    
    
   
    
}
-(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;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

相关文章

网友评论

      本文标题:2018-04-16

      本文链接:https://www.haomeiwen.com/subject/zpsskftx.html