UITabBarController

跟UINavigationController类似,UITabBarController也可以轻松地管理多个控制器,轻松完成控制器之间的切换,典型例子就是QQ、微信等应用

UITabBarController的简单使用

UITabBarController的使用步骤

  1. 初始化UITabBarController
  2. 设置UIWindow的rootViewController为UITabBarController
  3. 根据具体情况,通过addChildViewController方法添加对应个数的子控制器

UITabBarController的子控制器

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

1.添加单个子控制器

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

2.设置子控制器数组

@property(nonatomic,copy) NSArray *viewControllers;

UITabBar

如果UITabBarController有N个子控制器,那么UITabBar内部就会有N个UITabBarButton作为子控件

UITabBarButton

UITabBarButton里面显示什么内容,由对应子控制器的tabBarItem属性决定

UITabBarItem有以下属性影响着UITabBarButton的内容

标题文字

@property(nonatomic,copy) NSString *title;

图标

@property(nonatomic,retain) UIImage *image;

选中时的图标

@property(nonatomic,retain) UIImage *selectedImage;

提醒数字

@property(nonatomic,copy) NSString *badgeValue;

results matching ""

    No results matching ""