iOS开发中UITabBarController的使用示例

2020-01-14 16:38:32王冬梅

    tabBarViewB.tabBarItem.badgeValue = @"GO";  
      
#pragma mark  第三个视图ViewController  
    HMT_CViewController * tabBarViewC = [[HMT_CViewController alloc] init];  
    tabBarViewC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2];  
    // 设置B视图下----标签栏信息提示  
    tabBarViewC.tabBarItem.badgeValue = @"new";  
      
#pragma mark  第四个视图ViewController  
    HMT_DViewController * tabBarViewD = [[HMT_DViewController alloc] init];  
    tabBarViewD.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3];  
    // 设置B视图下----标签栏信息提示  
    tabBarViewD.tabBarItem.badgeValue = @"99";  
      
#pragma mark  第五个视图ViewController  
    HMT_EViewController * tabBarViewE = [[HMT_EViewController alloc] init];  
    tabBarViewE.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:4];  
    // 设置B视图下----标签栏信息提示  
    tabBarViewE.tabBarItem.badgeValue = @"sky";  
      
#pragma mark  第六个视图ViewController(系统默认能显示的最大视图个数是5个)  
    /* 如果你的viewControllers属性添加了多于五个的items,那tab bar controller将会自动插入一个特殊的view controller, 
    称为 More view controller,该 controller 将会负责管理多于的items,这个More view controller提供一个自定义的界面, 
    用table的方式呈现多余的view controller,并且view controller的数量是不限制的*/  
    HMT_FViewController * tabBarViewF = [[HMT_FViewController alloc] init];  
    tabBarViewF.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:5];  
    // 设置F视图下----标签栏信息提示  
    tabBarViewF.tabBarItem.badgeValue = @"AG";  
      
      
      
#pragma mark - 设置TabBarController  
      
    // 创建TabBarController