From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/CYLTabBarController/README.md | 938 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 938 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/CYLTabBarController/README.md b/screendisplay/Pods/CYLTabBarController/README.md new file mode 100644 index 0000000..dfc0f28 --- /dev/null +++ b/screendisplay/Pods/CYLTabBarController/README.md @@ -0,0 +1,938 @@ +# CYLTabBarController������������������TabBarController��� + + + +<p align="center"> +<a href=""><img src="https://img.shields.io/badge/pod-v1.17.4-brightgreen.svg"></a> +<a href=""><img src="https://img.shields.io/badge/Swift-compatible-orange.svg"></a> +<a href=""><img src="https://img.shields.io/badge/platform-iOS%207.0%2B-ff69b5152950834.svg"></a> +<a href="https://github.com/ChenYilong/CYLTabBarController/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat"></a> +</p> +<p align="center"> +<a href="https://twitter.com/stevechen1010"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social&maxAge=2592000"></a> +<a href="http://weibo.com/luohanchenyilong"><img src="http://i67.tinypic.com/wbulbr.jpg"></a> +<a href="https://gitter.im/ChenYilong/CYLTabBarController?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/ChenYilong/CYLTabBarController.svg"></a> +</p> + + +## ������ + +<!-- START doctoc generated TOC please keep comment here to allow auto update --> +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> + + +- [������������������TabBarController���������](#%E4%B8%8E%E5%85%B6%E4%BB%96%E8%87%AA%E5%AE%9A%E4%B9%89tabbarcontroller%E7%9A%84%E5%8C%BA%E5%88%AB) +- [���������������������](#%E9%9B%86%E6%88%90%E5%90%8E%E7%9A%84%E6%95%88%E6%9E%9C) +- [������������](#%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84) +- [������CYLTabBarController](#%E4%BD%BF%E7%94%A8cyltabbarcontroller) + - [������������������CocoaPods������CYLTabBarController](#%E7%AC%AC%E4%B8%80%E6%AD%A5%E4%BD%BF%E7%94%A8cocoapods%E5%AF%BC%E5%85%A5cyltabbarcontroller) + - [������������������CYLTabBarController������������������������������������TabBar������������](#%E7%AC%AC%E4%BA%8C%E6%AD%A5%E8%AE%BE%E7%BD%AEcyltabbarcontroller%E7%9A%84%E4%B8%A4%E4%B8%AA%E6%95%B0%E7%BB%84%E6%8E%A7%E5%88%B6%E5%99%A8%E6%95%B0%E7%BB%84%E5%92%8Ctabbar%E5%B1%9E%E6%80%A7%E6%95%B0%E7%BB%84) + - [���������������CYLTabBarController���������window���RootViewController](#%E7%AC%AC%E4%B8%89%E6%AD%A5%E5%B0%86cyltabbarcontroller%E8%AE%BE%E7%BD%AE%E4%B8%BAwindow%E7%9A%84rootviewcontroller) + - [���������������������������������������������������������������������](#%E7%AC%AC%E5%9B%9B%E6%AD%A5%E5%8F%AF%E9%80%89%E5%88%9B%E5%BB%BA%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E5%BD%A2%E7%8A%B6%E4%B8%8D%E8%A7%84%E5%88%99%E5%8A%A0%E5%8F%B7%E6%8C%89%E9%92%AE) +- [������������](#%E8%A1%A5%E5%85%85%E8%AF%B4%E6%98%8E) + - [��������� `TabBar` ������](#%E8%87%AA%E5%AE%9A%E4%B9%89-tabbar-%E6%A0%B7%E5%BC%8F) + - [������ TabBar ������������](#%E6%8D%95%E8%8E%B7-tabbar-%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6) + - [������ TabBarButton ���������������](#%E7%82%B9%E5%87%BB-tabbarbutton-%E6%97%B6%E6%B7%BB%E5%8A%A0%E5%8A%A8%E7%94%BB) + - [���������������](#%E6%A8%AA%E7%AB%96%E5%B1%8F%E9%80%82%E9%85%8D) + - [��������������������� CYLTabBarController ������](#%E8%AE%BF%E9%97%AE%E5%88%9D%E5%A7%8B%E5%8C%96%E5%A5%BD%E7%9A%84-cyltabbarcontroller-%E5%AF%B9%E8%B1%A1) + - [������ PlusButton ��������������� UIViewController](#%E7%82%B9%E5%87%BB-plusbutton-%E8%B7%B3%E8%BD%AC%E5%88%B0%E6%8C%87%E5%AE%9A-uiviewcontroller) + - [���TabBarItem������������������������������������������](#%E8%AE%A9tabbaritem%E4%BB%85%E6%98%BE%E7%A4%BA%E5%9B%BE%E6%A0%87%E5%B9%B6%E4%BD%BF%E5%9B%BE%E6%A0%87%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD) + - [���TabBar������������������PlusButton������](#%E5%A4%9Atabbar%E5%B5%8C%E5%A5%97%E5%B9%B6%E6%8C%87%E5%AE%9Aplusbutton%E4%BD%8D%E7%BD%AE) + - [��� Swift ��������������� CYLTabBarController](#%E5%9C%A8-swift-%E9%A1%B9%E7%9B%AE%E4%B8%AD%E4%BD%BF%E7%94%A8-cyltabbarcontroller) + - [������ Storyboard ������ CYLTabBarController](#%E6%90%AD%E9%85%8D-storyboard-%E4%BD%BF%E7%94%A8-cyltabbarcontroller) + - [������������������](#%E6%BA%90%E7%A0%81%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86) +- [FAQ](#faq) + +<!-- END doctoc generated TOC please keep comment here to allow auto update --> + + +## ������������������TabBarController��������� + + ������ |������ +-------------|------------- + ��������������������� | 1���TabBar���������������������������������������������������������������������������App���������������</p> 2��� PlusButton ������������������������������������������ `CYLPlusButton` ��������������������������������������������������������������� PlusButton ������������������������ + `TabBar` ������ `TabBar` ������ `TabBarItem` ������������������������������ | ������������������������������������ `UIButton` ��� `UIView` ������������������</p> 1. ������������������������������������������������������������</p> 2. ���push��������������� `TabBar` ������������������������������������������������������������������ [������������������](https://github.com/ChenYilong/CYLTabBarController#������������������) ��������������������������������� </p> 3. ���������������������������������������������API������������������������ ` [UITabBar appearance];` ���` [UITabBarItem appearance];` ���������������������������[������������](https://github.com/ChenYilong/CYLTabBarController#������������) ������������������������������������������ + ���������������������������������������������������</p>������������������������ |[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController) ��������������������������������������������� `TabBarController` ������������������������������������������������������������������������������������������������������������������������������������������ `TabBarController` ���������������������������������������������������������������[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController) ������������������������������������ `tabBar` ������������������������������������������������������������������������������������������</p>������������������������������frame���������������������������������������������������tabbar��������������� +���������������������������tabbar������������</p>��������������������������������������� | ������������������������������tabbar������������������������</p> +������������������������������ | ���������������</p> </p>Airbnb-app���������</p> +��������� `TabBarItem` ������������������������������������������������������������������TabBar������ | ������������Airbnb-app���������������������</p> + ��������������������� |  + ���������������������View |  + ���������TabBar������������������PlusButton������ |  +������CocoaPods |������������ +������Swift������������ | ������ +��������������� | ������ + + + + +���������������������515295083��� + + + +## ��������������������� +��������������������� | ������������������������������������������������������������ +-------------|------------ +|  + + ��������������� +  + + +���������������Demo������������| [���������Demo](https://github.com/ChenYilong/CYLTabBarControllerDemoForWeib) ������CYLTabBarController���������������Tabbar��������������������� +-------------|------------- +| + +## ������������ + + + + +��������������� + + ```Objective-C + +��������� CYLTabBarController ��������������������������������������� CocoaPods ������������������������������������������������������������ +��������� Example + ��������� Classes + ���� ��������� Module #������������������ + ������� ��������� Home + ������� ��������� Message + ������� ��������� Mine + ���� ������� ��������� SameCity + ���� ��������� View #������������ CYLPlusButton ��������� CYLPlusButtonSubclass��������������������������������������������������������������� + + + ``` + + +## ������[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController) + +������������������App��������������� + + 1. [ ������������������CocoaPods������CYLTabBarController ](https://github.com/ChenYilong/CYLTabBarController#���������������cocoapods������cyltabbarcontroller) + 2. [������������������CYLTabBarController������������������������������������TabBar������������](https://github.com/ChenYilong/CYLTabBarController#���������������cyltabbarcontroller���������������������������������tabbar������������) + 3. [���������������CYLTabBarController���������window���RootViewController](https://github.com/ChenYilong/CYLTabBarController#������������cyltabbarcontroller���������window���rootviewcontroller) + 4. [���������������������������������������������������������������������](https://github.com/ChenYilong/CYLTabBarController#������������������������������������������������������������) + + +### ������������������CocoaPods������CYLTabBarController + + 1. CocoaPods ������ + +�� ������������������������������������ CocoaPods��������������������������������� + +�� ������������������������������������������������������������������������������ + +�� ``` +�������� sudo gem install cocoapods +�� ``` + +�� ��������������������������������������������������� Ruby China ��� RubyGems ��������������������� + +�� ������������������������������������ + +�� ``` +�������� gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ +�������� sudo gem install cocoapods +�� ``` + + 2. ������ CocoaPods ��������������� + +�� ��������������������������������� + +�� ``` +�������� pod search CYLTabBarController +�� ``` + +���� ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� CocoaPods ������������ + +�� ``` +�������� pod repo update +�� ``` + + 3. ������ CocoaPods ������ + +�� ��������������������������������������������������������������������������������������� Podfile ��������� + +�� ``` +�������� pod init +�� ``` + +�� ������������ CocoaPods ��������������������������������� CocoaPods������������������������������������ + + ``` +������ gem install cocoapods + ``` + +�� ������ Podfile������������������ target ������������������������������������ v1.6.7 ��������������� + +�� ��������� `Podfile` ������������������������ + + ``` +������ pod 'CYLTabBarController', '~> 1.17.4' + ``` + +�� ��������������������������������������� + + ``` +������ pod install + ``` + +�� ��������������������� + + ``` +������ # ������������ CocoaPods ��� spec ������������������������ Analyzing dependencies������������ +������ pod update --verbose --no-repo-update + ``` + +�� ��������������������������������������� `--no-repo-update`��� + +�� ���������1.17.4���CocoaPods ������������������������������������������ `.xcworkspace` ������������������������������������������������������������������������ `.xcodeproj`��� + +**CocoaPods ������������** + +**������ CYLTabBarController ������** + +CocoaPods ��������������������� CYLTabBarController ������������������������ + +`>= 1.16.X` ��������������������� CocoaPods ��������������������������� `1.18.X` ��������� CYLTabBarController��� + +`~> 1.16.X` ��������������������� CocoaPods ������������������ 1.16.X~1.18.0 ��������������� CYLTabBarController��� +��������������������������������������������������������������� 1.17.4 ��������� + + +``` +������ pod 'CYLTabBarController', '~> 1.17.4' +``` + + - ������������ CocoaPods ��� + +�� `CocoaPods ������������������������������������������������ CocoaPods ������������������������ CYLTabBarController ��������� + + ��������������������������������������������������������������������������������������������������������������������� + + ``` +pod repo update + ``` + + - ��������������� CYLTabBarController ������ + + ������������������������ Podfile ��������� CYLTabBarController ��������������������������������������������� + + ``` +pod update + ``` + + + - ������ Cocoapods ������������ + + ��������������������������������������������������������� CocoaPods ������������������������������������ + + ������������������������ CocoaPods ���������(~/Library/Caches/CocoaPods/Pods/Release ������)������������������������ + + - ��������������������� CYLTabBarController ������ + + ������������ Podfile.lock ������������������������������������ CYLTabBarController ��������� + + ������ CocoaPods ��������������������������������� [CocoaPods ������](https://cocoapods.org/)��� + + +### ������������������CYLTabBarController������������������������������������TabBar������������ + + ```Objective-C + - (void)setupViewControllers { + CYLHomeViewController *firstViewController = [[CYLHomeViewController alloc] init]; + UIViewController *firstNavigationController = [[UINavigationController alloc] + initWithRootViewController:firstViewController]; + + CYLSameFityViewController *secondViewController = [[CYLSameFityViewController alloc] init]; + UIViewController *secondNavigationController = [[UINavigationController alloc] + initWithRootViewController:secondViewController]; + + + CYLTabBarController *tabBarController = [[CYLTabBarController alloc] init]; + [self customizeTabBarForController:tabBarController]; + + [tabBarController setViewControllers:@[ + firstNavigationController, + secondNavigationController, + ]]; + self.tabBarController = tabBarController; +} + +/* + * + ���`-setViewControllers:`������������TabBar������������ + * + */ +- (void)customizeTabBarForController:(CYLTabBarController *)tabBarController { + + NSDictionary *dict1 = @{ + CYLTabBarItemTitle : @"������", + CYLTabBarItemImage : @"home_normal", + CYLTabBarItemSelectedImage : @"home_highlight", + }; + NSDictionary *dict2 = @{ + CYLTabBarItemTitle : @"������", + CYLTabBarItemImage : @"mycity_normal", + CYLTabBarItemSelectedImage : @"mycity_highlight", + }; + + NSArray *tabBarItemsAttributes = @[ dict1, dict2 ]; + tabBarController.tabBarItemsAttributes = tabBarItemsAttributes; +} + ``` + +���������������������`CYLTabBarItemImage` ��� `CYLTabBarItemSelectedImage` ������ `NSString`���`UIImage` +���������������`CYLTabBarItemTitle` ������������������������������������������������������������������ + + +### ���������������CYLTabBarController���������window���RootViewController + + ```Objective-C + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + /* *��������������� * */ + [self.window setRootViewController:self.tabBarController]; + /* *��������������� * */ + return YES; +} + ``` + + +### ��������������������������������������������������������������������� + + +��������������������� CYLPlusButton ��������������������������� + + + 1. ������ `CYLPlusButtonSubclassing` ������ + + 2. ��������������������������������������������� `-application:didFinishLaunchingWithOptions:` ������������������ `[YourClass registerPlusButton]` + + ��������������������������������� `+load` ������������������������������������������������ iOS10 ������������ Crash ������������ + + ```Objective-C + + (void)load { + [super registerPlusButton]; + } + ``` + +������������������������������ + + ```Objective-C ++ (NSUInteger)indexOfPlusButtonInTabBar; ++ (CGFloat)multiplierOfTabBarHeight:(CGFloat)tabBarHeight; ++ (UIViewController *)plusChildViewController; ++ (BOOL)shouldSelectPlusChildViewController; + ``` + +������������������ + + ```Objective-C + + (NSUInteger)indexOfPlusButtonInTabBar; + ``` +��������������������������������������������������������������������������������� `tabbar` ��������������������������������������������������� `CYLTabBarController` ��������� `exception` ������������������ + +������������������������������ + + + +Airbnb-app��������� + + + + ```Objective-C ++ (CGFloat)multiplierOfTabBarHeight:(CGFloat)tabBarHeight; + ``` + +������������������������������������������������Y��������������������������������������������� `tabbar` ������������������������������������������������������������������Y������������������������ `tabbar` ������������������������������������������������������������������������������������������������������������������������������������������������ + +������������������������������������������������ PlusButton ��� centerY ������������������������ + +`PlusButtonCenterY = multiplierOfTabBarHeight * taBarHeight + constantOfPlusButtonCenterYOffset;` + +��������������������� constantOfPlusButtonCenterYOffset ���0��������� multiplierOfTabBarHeight ���������0.5��������� PlusButton ���������������0.5������ PlusButton ���������������0.5������������������ + + + ```Objective-C ++ (CGFloat)constantOfPlusButtonCenterYOffsetForTabBarHeight:(CGFloat)tabBarHeight; + ``` + +������ `+multiplierOfTabBarHeight:` ��������������� + +`PlusButtonCenterY = multiplierOfTabBarHeight * taBarHeight + constantOfPlusButtonCenterYOffset;` + +��������������� constantOfPlusButtonCenterYOffset ������0������������������������0������������������ + +��������������������������������������������� `+multiplierOfTabBarHeight:` ��������������������������������������������������������������������������� + +������Demo������ `CYLPlusButtonSubclass` ��������������� + + ```Objective-C ++ (UIViewController *)plusChildViewController; + ``` + +��������� [������ PlusButton ��������������� UIViewController](https://github.com/ChenYilong/CYLTabBarController#������-plusbutton-���������������-uiviewcontroller) + + +��������������������������������������������������������������������������������������� tabbar ������������������������������ AppDelegate ��������������� + + + ```Objective-C + //������ TabBar ��������������������� + [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; + ``` + +// iOS10 ��� ������������ `-[CYLTabBarController hideTabBadgeBackgroundSeparator]` ��� AppDelegate ���������������; + +������������������������ `PlusButton` ��������� `TabBarItem` ������������ + +`CYLTabBarController` ��������� + + ```Objective-C + TabBarItem ������ ��� ( TabBar ��������� ��� PlusButton ������ ) / (TabBarItem ������) + ``` + +������������������������������������������ `PlusButton` ������������������ + +��������������������� Demo������ `CYLPlusButtonSubclass.m` ��������� + +��� + + ```Objective-C + [button sizeToFit]; + ``` + +������ + + ```Objective-C + button.frame = CGRectMake(0.0, 0.0, 250, 100); + button.backgroundColor = [UIColor redColor]; + ``` + +��������������� +1.17.4 + + +��������������������������������� `CYLTabBarController` ��������������������� + + > ���������������������������tabbar��������������������������������������������������� + +��������������������������������������������������� `PlusButton` ������������������ `CYLTabBarController.h` ��������� `CYLPlusButtonWidth` ������extern������������ `+[CYLTabBarControllerConfig customizeTabBarAppearance:]` ��������������� + + + +## ������������ + + + +### ��������� `TabBar` ������ + +��������������������������������� `TabBar` ������������ `-application:didFinishLaunchingWithOptions:` ��������������� + + ```Objective-C + /** + * tabBarItem ������������������������������������������������ + */ +- (void)customizeInterface { + + // ������������������������������ + NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary]; + normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor]; + + // ������������������������������ + NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; + selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor]; + + // ������������������ + UITabBarItem *tabBar = [UITabBarItem appearance]; + [tabBar setTitleTextAttributes:normalAttrs forState:UIControlStateNormal]; + [tabBar setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected]; + + // ������������������ + UITabBar *tabBarAppearance = [UITabBar appearance]; + [tabBarAppearance setBackgroundImage:[UIImage imageNamed:@"tabbar_background"]]; +} + + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + /* *��������������� * */ + [self.window makeKeyAndVisible]; + [self customizeInterface]; + return YES; +} + ``` + +#### ������ TabBar ������������ + +������ CYLTabBarController ������������������������������������������������������ + + ������������������������������������������ `TabBar` ������������������������ `UITabBarButton`������������ `PlusButton`������������������������ `TabBar` ������������ `UIControl` ������������������������ `PlusButton` ��������������������������������������� `PlusButton` ��������������������������������������� + + ```Objective-C +//CYLTabBarController.h + +@protocol CYLTabBarControllerDelegate <NSObject> + +/*! + * @param tabBarController The tab bar controller containing viewController. + * @param control Selected UIControl in TabBar. + * @attention If PlusButton also add an action, then this delegate method will not be invoked when the PlusButton is selected. + */ +- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control; + +@end + + ``` + + ��������������������������������������������������������������������������������������������� + + ```Objective-C +//UITabBarController.h +@protocol UITabBarControllerDelegate <NSObject> +@optional +- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0); +@end + + ``` + +������������������������������������������������ +` [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController];` ��������� `PlusButton` ��������������������������������� + + ```Objective-C +- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { + [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController]; + return YES; +} + ``` + +��������������������� Demo ������������ + + ������������������������������ + + + ```Objective-C +@interface AppDelegate ()<UITabBarControllerDelegate, CYLTabBarControllerDelegate> + +@end + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + //... + tabBarControllerConfig.tabBarController.delegate = self; + //... + return YES; +} + ``` + +### ������ TabBarButton ��������������� + +Demo ��������������������� + + + +������������������������������������������������������������������������������������������������������ + + + ```Objective-C +//CYLTabBarController.h + +@protocol CYLTabBarControllerDelegate <NSObject> + +/*! + * @param tabBarController The tab bar controller containing viewController. + * @param control Selected UIControl in TabBar. + */ +- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control; + +@end + + ``` + + Demo ������������������������ + + ������������ + + + ```Objective-C +@interface AppDelegate ()<UITabBarControllerDelegate, CYLTabBarControllerDelegate> + +@end + ``` + + + ```Objective-C + //AppDelegate.m +- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control { + UIView *animationView; + // ������ PlusButton ��������������������������������������� PlusButton ��������������������������������� + if ([control isKindOfClass:[CYLExternPlusButton class]]) { + UIButton *button = CYLExternPlusButton; + animationView = button.imageView; + } else if ([control isKindOfClass:NSClassFromString(@"UITabBarButton")]) { + for (UIView *subView in control.subviews) { + if ([subView isKindOfClass:NSClassFromString(@"UITabBarSwappableImageView")]) { + animationView = subView; + } + } + } + + if ([self cyl_tabBarController].selectedIndex % 2 == 0) { + [self addScaleAnimationOnView:animationView]; + } else { + [self addRotateAnimationOnView:animationView]; + } +} + +//������������ +- (void)addScaleAnimationOnView:(UIView *)animationView { + //������������������������������������������������������ + CAKeyframeAnimation *animation = [CAKeyframeAnimation animation]; + animation.keyPath = @"transform.scale"; + animation.values = @[@1.0,@1.3,@0.9,@1.15,@0.95,@1.02,@1.0]; + animation.duration = 1; + animation.calculationMode = kCAAnimationCubic; + [animationView.layer addAnimation:animation forKey:nil]; +} + +//������������ +- (void)addRotateAnimationOnView:(UIView *)animationView { + [UIView animateWithDuration:0.32 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ + animationView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 1, 0); + } completion:nil]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [UIView animateWithDuration:0.70 delay:0 usingSpringWithDamping:1 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{ + animationView.layer.transform = CATransform3DMakeRotation(2 * M_PI, 0, 1, 0); + } completion:nil]; + }); +} + ``` + +### ��������������� + +`TabBar` ��������������������������������������� `PlusButton`������������������������ `TabBarItem` ���������, ������������������������`UIDeviceOrientationDidChangeNotification` , ������������������ `CYLTabBarItemWidthDidChangeNotification` ��������� `TabBar` ������������������������������������������ `TabBarItem` ������������������������������������������������������������`TabBarItem` ������������������Demo ��� `CYLTabBarControllerConfig.m` ������������������������������: + + + `CYLTabBarController.h` ������������ `CYLTabBarItemWidth` ������extern��������������������� `TabBarItem` ������������������������������������������������������������������������������ + + ```Objective-C +- (void)updateTabBarCustomizationWhenTabBarItemWidthDidUpdate { + void (^deviceOrientationDidChangeBlock)(NSNotification *) = ^(NSNotification *notification) { + [self tabBarItemWidthDidUpdate]; +}; + [[NSNotificationCenter defaultCenter] addObserverForName:CYLTabBarItemWidthDidChangeNotification + object:nil + queue:[NSOperationQueue mainQueue] + usingBlock:deviceOrientationDidChangeBlock]; +} + +- (void)tabBarItemWidthDidUpdate { + UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + if ((orientation == UIDeviceOrientationLandscapeLeft) || (orientation == UIDeviceOrientationLandscapeRight)) { + NSLog(@"Landscape Left or Right !"); + } else if (orientation == UIDeviceOrientationPortrait){ + NSLog(@"Landscape portrait!"); + } + CGSize selectionIndicatorImageSize = CGSizeMake(CYLTabBarItemWidth, [self cyl_tabBarController].tabBar.bounds.size.height); + [[self cyl_tabBarController].tabBar setSelectionIndicatorImage:[[self class] + imageFromColor:[UIColor yellowColor] + forSize:selectionIndicatorImageSize + withCornerRadius:0]]; +} + ``` + + + +### ��������������������� CYLTabBarController ������ + +������������ `NSObject` ��������� + + `CYLTabBarController.h` ������ `NSObject` ��������������������� `-cyl_tabBarController` ��������������������������������������������������������������������������������� `CYLTabBarController` ���������`-cyl_tabBarController` ��������������������������������������������������������� `+shareInstance` ��������������������� + +��������������� + + ```Objective-C +// CYLTabBarController.h + +@interface NSObject (CYLTabBarController) + +/** + * If `self` is kind of `UIViewController`, this method will return the nearest ancestor in the view controller hierarchy that is a tab bar controller. If `self` is not kind of `UIViewController`, it will return the `rootViewController` of the `rootWindow` as long as you have set the `CYLTabBarController` as the `rootViewController`. Otherwise return nil. (read-only) + */ +@property (nonatomic, readonly) CYLTabBarController *cyl_tabBarController; + +@end + ``` + +��������� + + + ```Objective-C +//������ CYLTabBarController.h +#import "CYLTabBarController.h" + +- (void)viewDidLoad { + [super viewDidLoad]; + CYLTabBarController *tabbarController = [self cyl_tabBarController]; + /*...*/ +} + ``` + +### ������ PlusButton ��������������� UIViewController + +������������������������������������������������ + + + +��������������������������� PlusButton ��������������������������������� TabBar ������������������������������������������������ UIViewController ��� + +��������������������������� `+indexOfPlusButtonInTabBar` ��������� PlusButton ������������ + +��������������������� + + + + +������������������������������������������������ `PlusButton` ������������������ + +```Objective-C ++ (BOOL)shouldSelectPlusChildViewController; +``` + +��������������� + + +```Objective-C ++ (BOOL)shouldSelectPlusChildViewController { + BOOL isSelected = CYLExternPlusButton.selected; + if (isSelected) { + NSLog(@"�������������������������%@���������%@������������������%@", @(__PRETTY_FUNCTION__), @(__LINE__), @"PlusButton is selected"); + } else { + NSLog(@"�������������������������%@���������%@������������������%@", @(__PRETTY_FUNCTION__), @(__LINE__), @"PlusButton is not selected"); + } + return YES; +} + +``` + +### ���TabBarItem������������������������������������������ + +������������������������������������������ `tabBarItemsAttributes`������������������ title ��������� + +������������Demo��������������������������������������������� + + +��������� | ��������� +-------------|------------- +| + +��������������������������������� Airbnb-app ������������ + + + +��������������������������������������������������� +��������� `-setViewControllers:` ��������������� `CYLTabBarController` ��� `imageInsets` ��� `titlePositionAdjustment` ������ + +������������������������������������������`TabBar` ������������ `TabBarItem` ��������������������������������������������������������������������������������������������������������������������������� + +��������������� + + +���������������Airbnb-app��������������������������������������������������������������� `TabBar` ��������������������������� `CYLTabBarController` ��� `tabBarHeight` ���������������������Demo��� `CYLTabBarControllerConfig.m` ������ `-customizeTabBarAppearance:` ������������������ + +������������������������������������������������������������������������������������������������������������������ `UITabBarSwappableImageView`��������� `CYLTabBarController` ������������������������������������ `SwappableImageView` ��������������������������������������� `pod update` ��� 1.5.5������������������ + + +### ���TabBar������������������PlusButton������ + +������������������������ >= v1.17.4��� + +������������ + +  + + +������ PlusButton ��������������������������� context��� + + ```Objective-C +//CYLPlusButtonSubclassing ++ (NSString *)tabBarContext; + + ``` + +������������ TabBarController ��� context ������������������PlusButton ��������������������� PlusButton ��� TabBarController ������������ context ������������������ context ������������������ + +��������������������� PlusButton ��������������������������������������������� TabBarController ��� context ��������������������������������������������������������� TabBarController ������ + + + +### ��� Swift ��������������� CYLTabBarController + +������������������������Swift Demo������������������ Example-Swift��� + +������[@WeMadeCode](https://github.com/WeMadeCode) ��������� Swift ��� Demo���������������������[WeMadeCode/CYLTabBarController-Swift](https://github.com/WeMadeCode/CYLTabBarController-Swift) + +��������������������������������������������������������� [���������������swift2.1 ��������������������������� ������������Tabbed������������]( http://www.jianshu.com/p/c5bc2eae0f55?nomobile=yes ) + +������������������������������������������������������������ PlusButton ������������������ +������������ PlusButton ������������������������������������������������ + + +### ������ Storyboard ������ CYLTabBarController + +[������](https://github.com/ChenYilong/CYLDeallocBlockExecutor) ������������������������CYLTabBarControllerTestDemo���������Demo��������������������� Storyboard ��������� + +### ������������������ + +��������� [���[Note] CYLTabBarController���]( http://www.jianshu.com/p/8758d8014f86 ) + +��������������������������� [ ***CocoaDocs���CYLTabBarController*** ](http://cocoadocs.org/docsets/CYLTabBarController/1.2.1/index.html) ��� + +## FAQ + + +������Q-A��������������������������������� [issue-FAQ](https://github.com/ChenYilong/CYLTabBarController/issues?utf8=���&q=+label%3AQ-A+) +Q������������������6���TabBarItem������������������ + +A��� + +Apple ��������� + + > ������ `TabBar` ���������������������5��� `TabBarItem` ������������������������������������������ + + +���������������Apple������������ `UITabBarItem` ������������������������������������������������������ `UIButton` ���������5��������������� + +������������������5��� `TabBarItem` ��������������������������������������������������������������� `TabBar` ���������6���������������������6������������������ `TabBarItem` ���������������������������������Apple������������������������������5��������������������������������� + +Q��������� demo ��������� item ������������������������������������������������������������������������ +  + + A���v1.5.5 ��������������������������������������������������������������������������������������������������������������������������������� + +Q��� ������������������������������������������ ��������������������� +<img width="409" alt="screen shot 2015-10-28 at 9 21 56 am" src="https://cloud.githubusercontent.com/assets/7238866/10777333/5d7811c8-7d55-11e5-88be-8cb11bbeaf90.png"> + +A��������������� Demo ��������������������������������������������� +��������� `CYLTabBarControllerConfig` ������������������������������ + + ```Objective-C +/** + * ������TabBar���������������������������tabBarItem ���������������������������������������������������tabbar ������������������ + */ +- (void)customizeTabBarAppearance:(CYLTabBarController *)tabBarController; + + ``` + +��������������� + + + +Q: ��� `ViewController` ��������� `self.title` ��� `tabBarItemsAttributes` ������������ `title` ��������������������������������������������������������������� + +A������ v1.0.7 ��������������������������� bug��������������������������� + +������������ `self.title = @"������"; ` ������������������������ `self.navigationItem.title = @"������"; ` + +`self.title = @"������"; ` ������������������������ `tabBarItemsAttributes` ������������ `title` ������������������������������������������������������ bug��������������������������������� + + + + + +��������������� + + ```Objective-C + + self.navigationItem.title = @"������"; //���sets navigation bar title.The right way to set the title of the navigation + self.tabBarItem.title = @"������23333"; //���sets tab bar title. Even the `tabBarItem.title` changed, this will be ignored in tabbar. + self.title = @"������1"; //���sets both of these. Do not do this������������ This may cause something strange like this : http://i68.tinypic.com/282l3x4.jpg + + ``` + + Q : ������������������������ `-[UIViewController cyl_popSelectTabBarChildViewControllerAtIndex:]` ��������������������������������������������������� + + + +A��� ��������� iOS ���������BUG������������iOS9.3������������������������������������������������������������������������������ `rootWindow` ��������������������������������������������������� `Appdelegate` ��������������������� + + + ```Objective-C +//#import "CYLTabBarController.h" + [[self cyl_tabBarController] rootWindow].backgroundColor = [UIColor whiteColor]; + ``` +Q:������������������������������������������������������������ icon ���������������49��������������������������������������� ������������������demo���������������������������������������������������������������? + +A: ������������������������������ `CYLTabBarController` ������������������������������ `UIButton` ��� frame ������������������������ + +������ button ���������������������������������������������������������������������������plus��������������������������������������������������������������������������������������������������������������������������������������������������� + + + +���������������������������������`UIControl` ������������������������ `UIImage` ��������������� + + +Q���������������iOS10������Crash���iOS9������������ + + +A��� + ������������������������������������ `-application:didFinishLaunchingWithOptions:` ������������������ `[YourClass registerPlusButton]` + + ��������������������������������� `+load` ������������������������������������������������ iOS10 ������������ Crash ������������ + + ```Objective-C + + (void)load { + [super registerPlusButton]; +} + ``` + +Q: ��������������������� `plusButton` ������������������ `ViewController`��������������������������������� `plusButton` ��������������������� `tabItem` ��������������������� `normal` ������������ + +A: ��������������������������������������� + + 1. ��������������� `tabBar` ��������� `delegate` ��������������� `tabBar` ��������������������������������������������� `selected` ��������������������������������������������������������������������������������������������������� + + ```Objective-C +- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { + [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController]; + return YES; +} + ``` + + 2. `plusButton` ������������������������������������������������������������������������������������������������������������������������ `pushViewController` ��������������������������������������������������������������������������������������������������������� + + ��������������������������� `plusButton` ������������������������,��������� `addTarget` ������������������������������������������������������ok��� + +A: `PlusButton` ������������ `TabBarItem` ������������������������ + +(��������� [issue#36](https://github.com/ChenYilong/CYLTabBarController/issues/36#issuecomment-269165471) ) + +������ Demo ������������������������������ + + ```Objective-C +[button sizeToFit]; + ``` + +��������� + + ```Objective-C +button.frame = CGRectMake(0.0, 0.0, w, h); + ``` + +��������������������������������������������������������������������������� + +������������������������������������������������������������������TabBarItem��������������� + + + ```Objective-C + [UIScreen mainScreen].bounds.size.width / [CYLTabBarController allItemsInTabBarCount] + ``` + +���������iOS��������������������������� [������@iOS������������](http://weibo.com/luohanchenyilong/) ��� + +---------- +Posted by [������@iOS������������](http://weibo.com/luohanchenyilong/) +������������������������������������������-���������-���������-������������ | [Creative Commons BY-NC-ND 3.0](http://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh) +<p align="center"><a href="http://weibo.com/u/1692391497?s=6uyXnP" target="_blank"><img border="0" src="http://service.t.sina.com.cn/widget/qmd/1692391497/b46c844b/1.png"/></a></a> + + -- Gitblit v1.8.0