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];
    }
  • 相关阅读:
    【转载】[教程]OpenSEES超简单易懂的入门第一课
    【转载】面向对象的非线性有限元方法
    与李文雄老师讨论有限元
    【转载】 Moving Beyond OpenGL 1.1 for Windows
    【转载】国外免费期刊全文数据库
    与李文雄老师讨论学术研究
    【转载】VS 2010和.NET 4.0之WPF 4改进全解析
    【转载】MFC中SDI、MDI框架各部分指针获取(网上找的,好东西大家一起分享,多谢原创作者!)
    【转载】一位院士——搞科研的几个条件
    Visual Studio 2010 step by step学习摘要
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/4222006.html
Copyright © 2011-2022 走看看