From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/CYLTabBarController/CYLTabBarController/CYLPlusButton.m | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/CYLTabBarController/CYLTabBarController/CYLPlusButton.m b/screendisplay/Pods/CYLTabBarController/CYLTabBarController/CYLPlusButton.m new file mode 100644 index 0000000..e94e7d2 --- /dev/null +++ b/screendisplay/Pods/CYLTabBarController/CYLTabBarController/CYLPlusButton.m @@ -0,0 +1,97 @@ +// +// CYLPlusButton.m +// CYLTabBarController +// +// v1.16.0 Created by ������@iOS������������ ( http://weibo.com/luohanchenyilong/ ) on 10/20/15. +// Copyright �� 2015 https://github.com/ChenYilong . All rights reserved. +// + +#import "CYLPlusButton.h" +#import "CYLTabBarController.h" +#import "UIViewController+CYLTabBarControllerExtention.h" + +CGFloat CYLPlusButtonWidth = 0.0f; +UIButton<CYLPlusButtonSubclassing> *CYLExternPlusButton = nil; +UIViewController *CYLPlusChildViewController = nil; + +@implementation CYLPlusButton + +#pragma mark - +#pragma mark - public Methods + ++ (void)registerPlusButton { + if (![self conformsToProtocol:@protocol(CYLPlusButtonSubclassing)]) { + return; + } + Class<CYLPlusButtonSubclassing> class = self; + UIButton<CYLPlusButtonSubclassing> *plusButton = [class plusButton]; + CYLExternPlusButton = plusButton; + CYLPlusButtonWidth = plusButton.frame.size.width; + if ([[self class] respondsToSelector:@selector(plusChildViewController)]) { + CYLPlusChildViewController = [class plusChildViewController]; + if ([[self class] respondsToSelector:@selector(tabBarContext)]) { + NSString *tabBarContext = [class tabBarContext]; + if (tabBarContext && tabBarContext.length) { + [CYLPlusChildViewController cyl_setContext:tabBarContext]; + } + } else { + [CYLPlusChildViewController cyl_setContext:NSStringFromClass([CYLTabBarController class])]; + } + [[self class] addSelectViewControllerTarget:plusButton]; + if ([[self class] respondsToSelector:@selector(indexOfPlusButtonInTabBar)]) { + CYLPlusButtonIndex = [[self class] indexOfPlusButtonInTabBar]; + } else { + [NSException raise:NSStringFromClass([CYLTabBarController class]) format:@"If you want to add PlusChildViewController, you must realizse `+indexOfPlusButtonInTabBar` in your custom plusButton class.���Chinese���������������������PlusChildViewController������������������������������������������plusButton��������� `+indexOfPlusButtonInTabBar`������������plusButton���������"]; + } + } +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" ++ (void)registerSubclass { + [self registerPlusButton]; +} +#pragma clang diagnostic pop + +- (void)plusChildViewControllerButtonClicked:(UIButton<CYLPlusButtonSubclassing> *)sender { + BOOL notNeedConfigureSelectionStatus = [[self class] respondsToSelector:@selector(shouldSelectPlusChildViewController)] && ![[self class] shouldSelectPlusChildViewController]; + if (notNeedConfigureSelectionStatus) { + return; + } + if (sender.selected) { + return; + } + sender.selected = YES; + CYLTabBarController *tabBarController = [sender cyl_tabBarController]; + NSInteger index = [tabBarController.viewControllers indexOfObject:CYLPlusChildViewController]; + @try { + [tabBarController setSelectedIndex:index]; + } @catch (NSException *exception) { + NSLog(@"�������������������������%@���������%@������������������%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception); + } +} + +#pragma mark - +#pragma mark - Private Methods + ++ (void)addSelectViewControllerTarget:(UIButton<CYLPlusButtonSubclassing> *)plusButton { + id target = self; + NSArray<NSString *> *selectorNamesArray = [plusButton actionsForTarget:target forControlEvent:UIControlEventTouchUpInside]; + if (selectorNamesArray.count == 0) { + target = plusButton; + selectorNamesArray = [plusButton actionsForTarget:target forControlEvent:UIControlEventTouchUpInside]; + } + [selectorNamesArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + SEL selector = NSSelectorFromString(obj); + [plusButton removeTarget:target action:selector forControlEvents:UIControlEventTouchUpInside]; + }]; + [plusButton addTarget:plusButton action:@selector(plusChildViewControllerButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; +} + +/** + * ������������������������������������normal������������������������������������selected������������������ + * ������������������������������������������������ UITabBarButton ������ + */ +- (void)setHighlighted:(BOOL)highlighted {} + +@end -- Gitblit v1.8.0