[翻译] 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

目录
相关文章
|
6月前
|
并行计算 算法 程序员
FreeLearning C/C++ 译文集翻译完成
FreeLearning C/C++ 译文集翻译完成
28 1
|
存储 自然语言处理 前端开发
从零写一个Recoil(翻译)
Rewriting Recoil from scratchrecoil是facebook编写的一个库,它之所以诞生是因为人体工程学、context的性能问题和useState。这是一个非常聪明的库,几乎每个人都会找到它的用途——如果你想了解更多,请查看这段解释视频。刚开始我被图论和recoil惊到了,但渐渐的理解后,感觉也没那么特别了。也许我也可以实现一个类似的东西。我自己实现的版本和recoil
232 0
从零写一个Recoil(翻译)
|
API 对象存储 iOS开发
|
存储 iOS开发 Perl
|
iOS开发 Perl 文件存储
|
Apache iOS开发 Perl