菜单栏UITabBarController

菜单栏UITabBarController 提供选择进入哪一个页面
通过一个数组 里面存储的是 视图控制器
UITabBarController 也是一个UIviewController

初始化一个菜单栏
首先得初始化几个视图控制器

 ViewController *group = [[ViewController alloc]init];
    NewViewController *news = [[NewViewController alloc]init];
    UserViewController *userInfo = [[UserViewController alloc]init];

初始化菜单栏

UITabBarController *tabBarCon = [[UITabBarController alloc]init];
    tabBarCon.view.tintColor = [UIColor blackColor];
    tabBarCon.viewControllers = @[group,news,userInfo];

    NSArray *titles =@[@"圈子",@"新闻",@"个人中心"];

找到 UITabBarController里面的 菜单栏视图 再找到 里面的TabBarItem的数组 数组里面存的是 视图控制器的数组viewControllers 对应的按钮

UITabBarItem *groupItem = tabBarCon.tabBar.items[0];

设置TabBarItem的标题

groupItem.title = @"圈子";

设置TabBarItem的图片

groupItem.image =[UIImage imageNamed:@"圈子"];

默认选项

 tabBarCon.selectedIndex = 1;

把菜单栏设置成窗口的根视图

self.window.rootViewController = tabBarCon;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ldl_csdn_ios

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值