从一个登陆页跳转到一个具有多个导航页面的工具栏控制器UITabbarController中

方法如下:

(一)新建一个继承于UITabBarController控制器的控制器,在内部绑定多个以视图控制器进行初始化的导航控制器

(二)在登录的事件中创建一个新的上述的控制器对象 直接跳转即可

新建工具栏控制器如下:

编辑LayoutViewController.h如下:

//
//  LayoutViewController.h
//  作业整理
//
//  Created by apple on 15/9/15.
//  Copyright (c) 2015年 LiuXun. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LayoutViewController : UITabBarController

@end
编辑 LayoutViewController.m如下:

//
//  LayoutViewController.m
//  作业整理
//
//  Created by apple on 15/9/15.
//  Copyright (c) 2015年 LiuXun. All rights reserved.
//

#import "LayoutViewController.h"

@interface LayoutViewController ()

@end

@implementation LayoutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.barTintColor = [UIColor blueColor];
    
    ViewController *vc1 = [[ViewController alloc] init];
    [self TabVC:self setVC:vc1 withTabTitle:@"记录"  withTabImgName:@"记录" withSecTabImgNam:@"记录1"];
    
    ChatViewController *vc2 = [[ChatViewController alloc] init];
    [self TabVC:self setVC:vc2 withTabTitle:@"交流"  withTabImgName:@"交流" withSecTabImgNam:@"交流1"];
    
    SquareViewController *vc3 = [[SquareViewController alloc] init];
    [self TabVC:self setVC:vc3 withTabTitle:@"广场"  withTabImgName:@"主题" withSecTabImgNam:@"主题1"];
    MoreFormViewController *vc4 = [[MoreFormViewController alloc] init];
    [self TabVC:self setVC:vc4 withTabTitle:@"更多"  withTabImgName:@"我" withSecTabImgNam:@"我1"];
    
}

// 将属性设置封装在一个成员方法中
-(void)TabVC:(UITabBarController *)tab1  setVC:(UIViewController *) vc withTabTitle:(NSString *)tabtit  withTabImgName:(NSString *) imgNam withSecTabImgNam: (NSString *) secImg
{
    UINavigationController *navc= [[UINavigationController alloc] initWithRootViewController:vc];
    navc.navigationBar.barTintColor = [UIColor blueColor];
    navc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName: [UIFont boldSystemFontOfSize:22]};
    navc.tabBarItem.title = tabtit;
    navc.tabBarItem.image = [UIImage imageNamed:imgNam];
    navc.tabBarItem.selectedImage = [[UIImage imageNamed:secImg] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [navc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:15]} forState:UIControlStateNormal];
    [navc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:15]} forState:UIControlStateSelected];
    [tab1  addChildViewController:navc];
}

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


@end
在登陆页调用如下:

      layVC = [[LayoutViewController alloc] init];
            [self.navigationController pushViewController:layVC animated:YES];
运行结果如下:





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值