iOS-UITabBarController的基本使用

2018-07-24  本文已影响187人  CDLOG

使用步骤:

1.初始化UITabBarController
2.设置UIWindow的rootViewController为UITabBarController
3.根据具体情况,通过addChildViewController方法添加对应个数的子控制器,添加的所有子控制器都保存在TabBarController的childViewControllers数组当中.

UITabBarController添加控制器的方式有2种

添加单个子控制器

UITabBarController *tabBar = [[UITabBarController alloc] init];
  
  UIViewController *vc1 = [[UIViewController alloc] init];
  vc1.view.backgroundColor = [UIColor redColor];
  设置标题
  vc1.tabBarItem.title = @"标题1";
  设置提醒数字
  vc1.tabBarItem.badgeValue = @"10";
  添加子控制器.
  [tabBar addChildViewController:vc1];
上一篇下一篇

猜你喜欢

热点阅读