创建底部标签控制器

#import "ViewController.h"

#import "oneViewController.h"

#import "twoViewController.h"

#import "threeViewController.h"

#import "fourViewController.h"

#import "fiveViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

//首先初始化controller

    oneViewController *one = [oneViewController new];

//创建第一个

    UINavigationController *oneNav = [[UINavigationController alloc]initWithRootViewController:one];

    oneNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"今日特卖" image:[UIImage imageNamed:@"aa"] selectedImage:[UIImage imageNamed:@"aa"]];

//第二个

    twoViewController *two = [twoViewController new];

    UINavigationController *twoNav = [[UINavigationController alloc]initWithRootViewController:two];

    twoNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"社区" image:[UIImage imageNamed:@"bb"] selectedImage:[UIImage imageNamed:@"bb"]];

//第三个

    threeViewController *three = [threeViewController new];

    UINavigationController *threeNav = [[UINavigationController alloc]initWithRootViewController:three];

    threeNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"升级权益" image:[UIImage imageNamed:@"cc"] selectedImage:[UIImage imageNamed:@"cc"]];

//第四个

    fourViewController *four = [fourViewController new];

    UINavigationController *fourNav = [[UINavigationController alloc]initWithRootViewController:four];

    fourNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"购物车" image:[UIImage imageNamed:@"dd"] selectedImage:[UIImage imageNamed:@"dd"]];

//第五个

    fiveViewController *five = [fiveViewController new];

    UINavigationController *fiveNav = [[UINavigationController alloc]initWithRootViewController:five];

    fiveNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"个人中心" image:[UIImage imageNamed:@"ee"] selectedImage:[UIImage imageNamed:@"ee"]];


    self.viewControllers=@[oneNav,twoNav,threeNav,fourNav,fiveNav];

}

@end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容