From 83b9d5c682b21d88133f24da0f94dd56bd79e687 Mon Sep 17 00:00:00 2001 From: 单军华 Date: Thu, 19 Jul 2018 13:38:55 +0800 Subject: [PATCH] change --- screendisplay/Pods/CYLTabBarController/CYLTabBarController/UITabBarItem+CYLTabBarControllerExtention.m | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/CYLTabBarController/CYLTabBarController/UITabBarItem+CYLTabBarControllerExtention.m b/screendisplay/Pods/CYLTabBarController/CYLTabBarController/UITabBarItem+CYLTabBarControllerExtention.m new file mode 100755 index 0000000..8316fab --- /dev/null +++ b/screendisplay/Pods/CYLTabBarController/CYLTabBarController/UITabBarItem+CYLTabBarControllerExtention.m @@ -0,0 +1,57 @@ +// +// CYLTabBarController.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 "UITabBarItem+CYLTabBarControllerExtention.h" +#import <objc/runtime.h> +#import "UIControl+CYLTabBarControllerExtention.h" + +@implementation UITabBarItem (CYLTabBarControllerExtention) + ++ (void)load { + [self cyl_swizzleSetBadgeValue]; +} + ++ (void)cyl_swizzleSetBadgeValue { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + cyl_ClassMethodSwizzle([self class], @selector(setBadgeValue:), @selector(cyl_setBadgeValue:)); + }); +} + +- (void)cyl_setBadgeValue:(NSString *)badgeValue { + [self.cyl_tabButton cyl_removeTabBadgePoint]; + [self cyl_setBadgeValue:badgeValue]; +} + +- (UIControl *)cyl_tabButton { + UIControl *control = [self valueForKey:@"view"]; + return control; +} + +#pragma mark - private method + +BOOL cyl_ClassMethodSwizzle(Class aClass, SEL originalSelector, SEL swizzleSelector) { + Method originalMethod = class_getInstanceMethod(aClass, originalSelector); + Method swizzleMethod = class_getInstanceMethod(aClass, swizzleSelector); + BOOL didAddMethod = + class_addMethod(aClass, + originalSelector, + method_getImplementation(swizzleMethod), + method_getTypeEncoding(swizzleMethod)); + if (didAddMethod) { + class_replaceMethod(aClass, + swizzleSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzleMethod); + } + return YES; +} + +@end -- Gitblit v1.8.0