zoukankan      html  css  js  c++  java
  • [翻译] RDVTabBarController

    RDVTabBarController

    https://github.com/robbdimitrov/RDVTabBarController

    效果:

    • Supports iPad and iPhone 支持iPad与iPhone
    • Supports landscape and portrait orientations 支持横竖屏切换动画
    • Can be used inside UINavigationController 可以用在UINavigationController里面
    • Customizable badges 可定制的提示标签

    Installation 安装

    CocoaPods - cocoaPods

    If you're using CocoaPods, simply add pod 'RDVTabBarController' to your Podfile.

    如果你使用了CocoaPods,简单的pod ‘RDVTabBarController’ 到你的Podfile文件中就行了。

    Drag & Drop - 拖到项目当中

    Add the items from RDVTabBarController directory to your project. If you don't have ARC enabled, you will need to set a -fobjc-arc compiler flag on the .m source files.

    直接将RDVTabBarController文件夹拖到你的项目当中。如果你的项目是MRC的,你需要在.m文件里面设置-fobjc-arc编译标签。

    Example Usage - 使用示例

    Initialize RDVTabBarController

    初始化RDVTabBarController

    The initialization is similar to the one for UITabBarController. Create an instance of the tabBarController and initialize its viewControllers.

    初始化方法与UITabBarController类似,创建一个tabBarController的实例以及初始化控制器。

    UIViewController *firstViewController = [[RDVFirstViewController alloc] init];
    UIViewController *firstNavigationController = [[UINavigationController alloc]
                                                   initWithRootViewController:firstViewController];
    
    UIViewController *secondViewController = [[RDVSecondViewController alloc] init];
    UIViewController *secondNavigationController = [[UINavigationController alloc]
                                                    initWithRootViewController:secondViewController];
    
    UIViewController *thirdViewController = [[RDVThirdViewController alloc] init];
    UIViewController *thirdNavigationController = [[UINavigationController alloc]
                                                   initWithRootViewController:thirdViewController];
    
    RDVTabBarController *tabBarController = [[RDVTabBarController alloc] init];
    [tabBarController setViewControllers:@[firstNavigationController, secondNavigationController,
                                           thirdNavigationController]];
    self.viewController = tabBarController;

    Customize RDVTabBarController - 定制RDVTabBarController

    Each RDVTabBarItem has selectedBackgroundunselectedBackground and corresponding properties for the icons: selectedImage and unselectedImage.

    每一个RDVTabBarItem都有选择被背景与未选择的背景,或者是对应于选择的图片与未选择的图片。

    UIImage *finishedImage = [UIImage imageNamed:@"tabbar_selected_background"];
    UIImage *unfinishedImage = [UIImage imageNamed:@"tabbar_normal_background"];
    NSArray *tabBarItemImages = @[@"first", @"second", @"third"];
    
    RDVTabBar *tabBar = [tabBarController tabBar];
    
    [tabBar setFrame:CGRectMake(CGRectGetMinX(tabBar.frame), CGRectGetMinY(tabBar.frame), CGRectGetWidth(tabBar.frame), 63)];
    
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[tabBarController tabBar] items]) {
        [item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage];
        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",
                                                      [tabBarItemImages objectAtIndex:index]]];
        UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",
                                                        [tabBarItemImages objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
    
        index++;
    }

    Make the tab bar translucent - 可以让tab bar变得半透明

    RDVTabBar has translucent property which determines how it is going to be handled.

    RDVTabBar有着半透明色这个属性,他决定着怎么个透明方式。

    RDVTabBar *tabBar = tabBarController.tabBar;
    
    // After the tabBarController initialization
    tabBar.translucent = YES;
    
    // Customize the tabBar background
    tabBar.backgroundView.backgroundColor = [UIColor colorWithRed:245/255.0
                                                            green:245/255.0
                                                             blue:245/255.0
                                                            alpha:0.9]];
    
    // Inside the tabbed viewControllers
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        ...
    
        if (self.rdv_tabBarController.tabBar.translucent) {
            CGFloat tabBarHeight = CGRectGetHeight(self.rdv_tabBarController.tabBar.frame);
            UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, tabBarHeight, 0);
    
            self.tableView.contentInset = insets;
            self.tableView.scrollIndicatorInsets = insets;
        }
    }
    

    Requirements - 需要的环境

    • ARC 
    • iOS 5.0 or later
    • Xcode 5

     

    Contact

    Robert Dimitrov
    @robbdimitrov

  • 相关阅读:
    HDU 5107 线段树扫描线
    多线程之多生产多消费者
    matlab @
    全概率公式
    正确理解HTML,XHTML页面的头部doctype定义
    每天过的非常充实。
    struts2对action中的方法进行输入校验(2)
    Ubuntu下Chromium源码的编译
    LCA 最近公共祖先 tarjan离线 总结 结合3个例题
    VS2010-win32下cocos2dx控制台打印的方法
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4166416.html
Copyright © 2011-2022 走看看