标签栏不用库函数

//显示第一个界面, 加入导航控制器

    MainViewController *mvc = [[MainViewController alloc] init];

    mvc.title = @"主界面";    //设置title显示导航条上

    mvc.tabBarItem.image = [UIImage imageNamed:@"tab_0.png"];

    

    //创建导航控制器, 让导航控制器管理mvc

    //  设置一个普通视图控制器作为根视图控制器

    UINavigationController *nc1 = [[UINavigationController alloc] initWithRootViewController:mvc];

    

    //创建第二个界面

    ContactsViewController *cvc = [[ContactsViewController alloc] init];

    cvc.title = @"联系人";

    cvc.tabBarItem.image = [UIImage imageNamed:@"tab_1.png"];

    UINavigationController *nc2 = [[UINavigationController alloc] initWithRootViewController:cvc];

    

    //第三个界面

    DynamicViewController *dvc = [[DynamicViewController alloc] init];

    dvc.title = @"动态";

    dvc.tabBarItem.image = [UIImage imageNamed:@"tab_2.png"];

    UINavigationController *nc3 = [[UINavigationController alloc] initWithRootViewController:dvc];

    

    //第四个界面

    SettingViewController *svc = [[SettingViewController alloc] init];

    svc.title = @"设置";

    svc.tabBarItem.image = [UIImage imageNamed:@"tab_3.png"];

    UINavigationController *nc4 = [[UINavigationController alloc] initWithRootViewController:svc];

    

    //创建标签栏

    UITabBarController *tbc = [[UITabBarController alloc] init];

    tbc.viewControllers = @[nc1,nc2,nc3,nc4];

    

    self.window.rootViewController = tbc;

    

    //标签栏默认高度49

    [tbc.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];

    //设置选中的颜色

    tbc.tabBar.tintColor = [UIColor redColor];

    

    self.window.backgroundColor = [UIColor whiteColor];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值