diff --git a/.gitignore b/.gitignore index 67051a79..2a741a43 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Break *.xcuserstate *.xcbkptlist *.xcuserstate +*.xcbkptlist diff --git a/CYLTabBarController.xcodeproj/project.xcworkspace/xcuserdata/chenyilong.xcuserdatad/UserInterfaceState.xcuserstate b/CYLTabBarController.xcodeproj/project.xcworkspace/xcuserdata/chenyilong.xcuserdatad/UserInterfaceState.xcuserstate index bc3c9086..b2a652ee 100644 Binary files a/CYLTabBarController.xcodeproj/project.xcworkspace/xcuserdata/chenyilong.xcuserdatad/UserInterfaceState.xcuserstate and b/CYLTabBarController.xcodeproj/project.xcworkspace/xcuserdata/chenyilong.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index e74390d3..1fd1ed4c 100644 --- a/CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -36,7 +36,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "CYLTabBarController/CYLTabBarController.m" - timestampString = "519062970.556879" + timestampString = "519151512.189774" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "212" @@ -52,7 +52,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "CYLTabBarController/CYLTabBarController.m" - timestampString = "519062970.556879" + timestampString = "519151512.189913" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "210" @@ -67,8 +67,8 @@ symbolName = "-[CYLTabBarController setViewControllers:]" moduleName = "CYLTabBarController" usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/chenyilong/Documents/CYL/CYLTabBarController/CYLTabBarController/CYLTabBarController.m" - timestampString = "519137468.917978" + urlString = "file:///Users/chenyilong/Documents/Git/%E7%AC%AC%E4%B8%89%E6%96%B9/CYLTabBarController/CYLTabBarController/CYLTabBarController.m" + timestampString = "519151624.53257" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "210" @@ -82,8 +82,8 @@ symbolName = "-[CYLTabBarController setViewControllers:]" moduleName = "CYLTabBarController" usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/chenyilong/Documents/CYL/CYLTabBarController/CYLTabBarController/CYLTabBarController.m" - timestampString = "519137468.919809" + urlString = "file:///Users/chenyilong/Documents/Git/%E7%AC%AC%E4%B8%89%E6%96%B9/CYLTabBarController/CYLTabBarController/CYLTabBarController.m" + timestampString = "519151624.534434" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "210" @@ -99,13 +99,13 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "CYLTabBarController/CYLPlusButton.m" - timestampString = "502563700.837366" + filePath = "CYLTabBarController/CYLTabBarController.m" + timestampString = "519151512.190002" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "63" - endingLineNumber = "63" - landmarkName = "+addSelectViewControllerTarget:" + startingLineNumber = "271" + endingLineNumber = "271" + landmarkName = "-getImageFromImageInfo:" landmarkType = "7"> @@ -115,29 +115,29 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "CYLTabBarController/CYLPlusButton.m" - timestampString = "502563700.837366" + filePath = "CYLTabBarController/UIControl+CYLTabBarControllerExtention.m" + timestampString = "519152834.205129" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "62" - endingLineNumber = "62" - landmarkName = "+addSelectViewControllerTarget:" + startingLineNumber = "28" + endingLineNumber = "28" + landmarkName = "-cyl_setShowTabBadgePoint:" landmarkType = "7"> @@ -147,13 +147,13 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "CYLTabBarController/CYLTabBarController.m" - timestampString = "519062970.556879" + filePath = "Example/AppDelegate.m" + timestampString = "519152834.205264" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "271" - endingLineNumber = "271" - landmarkName = "-getImageFromImageInfo:" + startingLineNumber = "96" + endingLineNumber = "96" + landmarkName = "-tabBarController:shouldSelectViewController:" landmarkType = "7"> diff --git a/CYLTabBarController/UIControl+CYLTabBarControllerExtention.h b/CYLTabBarController/UIControl+CYLTabBarControllerExtention.h index d155a71b..46630d7d 100644 --- a/CYLTabBarController/UIControl+CYLTabBarControllerExtention.h +++ b/CYLTabBarController/UIControl+CYLTabBarControllerExtention.h @@ -22,9 +22,8 @@ - (void)cyl_removeTabBadgePoint; - (BOOL)cyl_isShowTabBadgePoint; - (void)cyl_setShowTabBadgePoint:(BOOL)showTabBadgePoint; - -@property (nonatomic, strong, setter=cyl_setTabBadgePointView:, getter=cyl_tabBadgePointView) UIView *tabBadgePointView; - -@property (nonatomic, assign, setter=cyl_setTabBadgePointViewOffset:, getter=cyl_tabBadgePointViewOffset) UIOffset tabBadgePointViewOffset; +//- (void)cyl_setTabBadgePointSize:(CGSize)size; +@property (nonatomic, strong, setter=cyl_setTabBadgePointView:, getter=cyl_tabBadgePointView) UIView *cyl_tabBadgePointView; +@property (nonatomic, assign, setter=cyl_setTabBadgePointViewOffset:, getter=cyl_tabBadgePointViewOffset) UIOffset cyl_tabBadgePointViewOffset; @end diff --git a/CYLTabBarController/UIControl+CYLTabBarControllerExtention.m b/CYLTabBarController/UIControl+CYLTabBarControllerExtention.m index 36a02993..0a3ed075 100644 --- a/CYLTabBarController/UIControl+CYLTabBarControllerExtention.m +++ b/CYLTabBarController/UIControl+CYLTabBarControllerExtention.m @@ -21,35 +21,35 @@ - (void)cyl_removeTabBadgePoint { } - (BOOL)cyl_isShowTabBadgePoint { - return !self.tabBadgePointView.hidden; + return !self.cyl_tabBadgePointView.hidden; } - (void)cyl_setShowTabBadgePoint:(BOOL)showTabBadgePoint { - if (showTabBadgePoint && self.tabBadgePointView.superview == nil) { - [self addSubview:self.tabBadgePointView]; - [self bringSubviewToFront:self.tabBadgePointView]; - self.tabBadgePointView.layer.zPosition = MAXFLOAT; - // X + if (showTabBadgePoint && self.cyl_tabBadgePointView.superview == nil) { + [self addSubview:self.cyl_tabBadgePointView]; + [self bringSubviewToFront:self.cyl_tabBadgePointView]; + self.cyl_tabBadgePointView.layer.zPosition = MAXFLOAT; + // X constraint [self addConstraint: - [NSLayoutConstraint constraintWithItem:self.tabBadgePointView //self.cyl_imageView + [NSLayoutConstraint constraintWithItem:self.cyl_tabBadgePointView attribute:NSLayoutAttributeCenterX relatedBy:0 toItem:self.cyl_imageView attribute:NSLayoutAttributeRight multiplier:1 - constant:self.tabBadgePointViewOffset.horizontal]]; - //Y + constant:self.cyl_tabBadgePointViewOffset.horizontal]]; + //Y constraint [self addConstraint: - [NSLayoutConstraint constraintWithItem:self.tabBadgePointView //self.cyl_imageView + [NSLayoutConstraint constraintWithItem:self.cyl_tabBadgePointView attribute:NSLayoutAttributeCenterY relatedBy:0 toItem:self.cyl_imageView attribute:NSLayoutAttributeTop multiplier:1 - constant:self.tabBadgePointViewOffset.vertical]]; + constant:self.cyl_tabBadgePointViewOffset.vertical]]; } - self.tabBadgePointView.hidden = showTabBadgePoint == NO; + self.cyl_tabBadgePointView.hidden = showTabBadgePoint == NO; self.cyl_tabBadgeView.hidden = showTabBadgePoint == YES; } @@ -109,6 +109,7 @@ - (UIImageView *)cyl_tabImageView { } return nil; } + - (UILabel *)cyl_tabLabel { for (UILabel *subview in self.subviews) { if ([subview cyl_isTabLabel]) { @@ -121,31 +122,8 @@ - (UILabel *)cyl_tabLabel { #pragma mark - private method - (UIView *)cyl_defaultTabBadgePointView { - CGFloat const defaultTabBadgePointViewRadius = 4.5; - UIView * defaultTabBadgePointView = [[UIView alloc] init]; - [defaultTabBadgePointView setTranslatesAutoresizingMaskIntoConstraints:NO]; - defaultTabBadgePointView.backgroundColor = [UIColor redColor]; - defaultTabBadgePointView.layer.cornerRadius = defaultTabBadgePointViewRadius; - defaultTabBadgePointView.layer.masksToBounds = YES; - defaultTabBadgePointView.hidden = YES; - // Width constraint - [defaultTabBadgePointView addConstraint:[NSLayoutConstraint constraintWithItem:defaultTabBadgePointView - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute: NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:defaultTabBadgePointViewRadius * 2]]; - - // Height constraint - [defaultTabBadgePointView addConstraint:[NSLayoutConstraint constraintWithItem:defaultTabBadgePointView - attribute:NSLayoutAttributeHeight - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute: NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:defaultTabBadgePointViewRadius * 2]]; - return defaultTabBadgePointView; + UIView *defaultRedTabBadgePointView = [UIView cyl_tabBadgePointViewWithClolor:[UIColor redColor] radius:4.5]; + return defaultRedTabBadgePointView; } @end diff --git a/CYLTabBarController/UIView+CYLTabBarControllerExtention.h b/CYLTabBarController/UIView+CYLTabBarControllerExtention.h index ba5e70e8..06afec80 100644 --- a/CYLTabBarController/UIView+CYLTabBarControllerExtention.h +++ b/CYLTabBarController/UIView+CYLTabBarControllerExtention.h @@ -7,6 +7,7 @@ // #import +#import @interface UIView (CYLTabBarControllerExtention) @@ -16,4 +17,6 @@ - (BOOL)cyl_isTabLabel; - (BOOL)cyl_isTabBadgeView; ++ (UIView *)cyl_tabBadgePointViewWithClolor:(UIColor *)color radius:(CGFloat)radius; + @end diff --git a/CYLTabBarController/UIView+CYLTabBarControllerExtention.m b/CYLTabBarController/UIView+CYLTabBarControllerExtention.m index 31dac948..a65bd008 100644 --- a/CYLTabBarController/UIView+CYLTabBarControllerExtention.m +++ b/CYLTabBarController/UIView+CYLTabBarControllerExtention.m @@ -71,4 +71,30 @@ - (BOOL)cyl_classStringhasPrefix:(NSString *)subString { return [classString hasPrefix:subString]; } ++ (UIView *)cyl_tabBadgePointViewWithClolor:(UIColor *)color radius:(CGFloat)radius { + UIView *defaultTabBadgePointView = [[UIView alloc] init]; + [defaultTabBadgePointView setTranslatesAutoresizingMaskIntoConstraints:NO]; + defaultTabBadgePointView.backgroundColor = color; + defaultTabBadgePointView.layer.cornerRadius = radius; + defaultTabBadgePointView.layer.masksToBounds = YES; + defaultTabBadgePointView.hidden = YES; + // Width constraint + [defaultTabBadgePointView addConstraint:[NSLayoutConstraint constraintWithItem:defaultTabBadgePointView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute: NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:radius * 2]]; + // Height constraint + [defaultTabBadgePointView addConstraint:[NSLayoutConstraint constraintWithItem:defaultTabBadgePointView + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute: NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:radius * 2]]; + return defaultTabBadgePointView; +} + @end diff --git a/CYLTabBarController/UIViewController+CYLTabBarControllerExtention.h b/CYLTabBarController/UIViewController+CYLTabBarControllerExtention.h index 9c132138..375abbd5 100644 --- a/CYLTabBarController/UIViewController+CYLTabBarControllerExtention.h +++ b/CYLTabBarController/UIViewController+CYLTabBarControllerExtention.h @@ -20,9 +20,9 @@ typedef void (^CYLPushOrPopCallback)(NSArray<__kindof UIViewController *> *viewC @interface UIViewController (CYLTabBarControllerExtention) -@property (nonatomic, strong, setter=cyl_setTabBadgePointView:, getter=cyl_tabBadgePointView) UIView *tabBadgePointView; +@property (nonatomic, strong, setter=cyl_setTabBadgePointView:, getter=cyl_tabBadgePointView) UIView *cyl_tabBadgePointView; -@property (nonatomic, assign, setter=cyl_setTabBadgePointViewOffset:, getter=cyl_tabBadgePointViewOffset) UIOffset tabBadgePointViewOffset; +@property (nonatomic, assign, setter=cyl_setTabBadgePointViewOffset:, getter=cyl_tabBadgePointViewOffset) UIOffset cyl_tabBadgePointViewOffset; @property (nonatomic, readonly, getter=cyl_isEmbedInTabBarController) BOOL cyl_embedInTabBarController; diff --git a/Example/AppDelegate.m b/Example/AppDelegate.m index 062bc2c3..00449100 100644 --- a/Example/AppDelegate.m +++ b/Example/AppDelegate.m @@ -15,6 +15,7 @@ @interface AppDelegate ()