[翻译] 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?selectedBackground,?unselectedBackground?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
?
轉載于:https://www.cnblogs.com/YouXianMing/p/4166416.html
總結
以上是生活随笔為你收集整理的[翻译] RDVTabBarController的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: qt 状态栏
- 下一篇: 高性能IO设计的Reactor和Proa