UITabBarController的简单使用

UITabBarController的使用步骤

初始化UITabBarController

设置UIWindow的rootViewController为UITabBarController

根据具体情况,通过addChildViewController方法添加对应个数的子控制器

通常而言,UITabBarController一般作为应用程序的rootViewController,而且它不能作为UINavigationController的rootViewController.

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

添加单个子控制器

- (void)addChildViewController:(UIViewController *)childController;

设置子控制器数组

@property (nonatomic,copy)NSArray*viewControllers;

示例:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Storyboard创建:

拖一个 UITabBarController

脱线:

设置tabBar:选中tabBarItem,设置tabBar的属性

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0