zoukankan      html  css  js  c++  java
  • xcode6 自定义UITabbarController

    -(void)initTabBarView{
        if (tabBarController && [kAPPDELEGATE.navigationController.viewControllers containsObject:tabBarController]) {
            [kAPPDELEGATE.navigationController popToViewController:tabBarController animated:YES];
            return;
        }
        [kAPPDELEGATE.navigationController popToRootViewControllerAnimated:NO];
        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        NSMutableArray *controllers = [NSMutableArray array];
        
      
        //UIImageRenderingModeAlwaysOriginal 图片按照原样渲染。
        {
            SchoolSecondHandViewController *vc = [[SchoolSecondHandViewController alloc] initWithNibName:nil bundle:nil];
            UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
           
            [item setTitleTextAttributes:[NSDictionary
                                          dictionaryWithObjectsAndKeys: [UIColor redColor],
                                          NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];
            vc.tabBarItem = item;
            [controllers addObject:vc];
        }
        {
            
            CollectSomeThingViewController *vc = [[CollectSomeThingViewController alloc] initWithNibName:nil bundle:nil];
           UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [item setTitleTextAttributes:[NSDictionary
                                          dictionaryWithObjectsAndKeys: [UIColor redColor],
                                          NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];
            vc.tabBarItem = item;
            [controllers addObject:vc];
            
        }
        {
            
            LossSomeThingViewController *vc = [[LossSomeThingViewController alloc] initWithNibName:nil bundle:nil];
          
            UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [item setTitleTextAttributes:[NSDictionary
                                          dictionaryWithObjectsAndKeys: [UIColor redColor],
                                          NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];
            vc.tabBarItem = item;
            [controllers addObject:vc];
            
        }
        {
            
            MoreViewController *vc = [[MoreViewController alloc] initWithNibName:nil bundle:nil];
            UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [item setTitleTextAttributes:[NSDictionary
                                          dictionaryWithObjectsAndKeys: [UIColor redColor],
                                          NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];
            vc.tabBarItem = item;
            [controllers addObject:vc];
            
        }
        
        tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
        tabBarController.delegate = self;
        tabBarController.tabBar.clipsToBounds = TRUE;
        
        {
            tabBarController.tabBar.tintColor = kDEFAULT_BG_COLOR;
            [[UITabBar appearance] setBackgroundImage:[ZQUtiles imageWithColor:kDEFAULT_BG_COLOR size:CGSizeMake(29, 1)]];//设置背景,修改颜色是没有用的
            
            [[UITabBar appearance] setSelectionIndicatorImage:[ZQUtiles imageWithColor:kDEFAULT_BG_COLOR size:CGSizeMake(29, 1)]];
        }
        [tabBarController setViewControllers:controllers];
        [kAPPDELEGATE.navigationController pushViewController:tabBarController animated:YES];
    }
  • 相关阅读:
    day28-描述符应用与类的装饰器
    MySQL-快速入门(8)存储过程、存储函数
    MySQL-快速入门(7)索引
    MySQL-快速入门(6)连接查询、子查询、正则表达式查询、数据的插入删除更新
    MySQL-快速入门(5)数据查询-常用关键字、分组查询、聚合函数
    MySQL-快速入门(4)MySQL函数
    MySQL-快速入门(3)运算符
    MySQL-快速入门(2)数据类型
    MySQL-快速入门(1)基本数据库、表操作语句
    MySql-Mysql技术内幕~SQL编程学习笔记(N)
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/4222006.html
Copyright © 2011-2022 走看看