From e9b9265a8dc3029cfce4a11ffda9831d69705fed Mon Sep 17 00:00:00 2001 From: zgy <173678978@qq.com> Date: Mon, 22 Jan 2018 16:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DbadgeRadius=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=97=A0=E6=95=88=E7=9A=84bug=EF=BC=8Cdemo=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E8=BF=99=E4=B8=AA=E5=B1=9E=E6=80=A7=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=B2=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WZLBadge/View/UIView+WZLBadge.m | 4 ++++ WZLBadgeDemo.xcodeproj/project.pbxproj | 7 +++---- WZLBadgeDemo/Base.lproj/Main.storyboard | 21 +++++++++++++-------- WZLBadgeDemo/ViewController.m | 4 ++++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/WZLBadge/View/UIView+WZLBadge.m b/WZLBadge/View/UIView+WZLBadge.m index ef8fb91..992caa2 100644 --- a/WZLBadge/View/UIView+WZLBadge.m +++ b/WZLBadge/View/UIView+WZLBadge.m @@ -159,6 +159,10 @@ - (void)badgeInit if (nil == self.badge) { CGFloat redotWidth = kWZLBadgeDefaultRedDotRadius *2; + if (self.badgeRadius) { + redotWidth = self.badgeRadius *2; + } + CGRect frm = CGRectMake(CGRectGetWidth(self.frame), -redotWidth, redotWidth, redotWidth); self.badge = [[UILabel alloc] initWithFrame:frm]; self.badge.textAlignment = NSTextAlignmentCenter; diff --git a/WZLBadgeDemo.xcodeproj/project.pbxproj b/WZLBadgeDemo.xcodeproj/project.pbxproj index 1d255cb..c7f4038 100644 --- a/WZLBadgeDemo.xcodeproj/project.pbxproj +++ b/WZLBadgeDemo.xcodeproj/project.pbxproj @@ -115,8 +115,7 @@ 19AD4E881BB3D4600059AA66 /* UITabBarItem+WZLBadge.h */, 19AD4E891BB3D4600059AA66 /* UITabBarItem+WZLBadge.m */, ); - name = BarItem; - path = BarButtonItem; + path = BarItem; sourceTree = ""; }; 1968600A1B78AB4A00AD10C2 /* View */ = { @@ -491,7 +490,7 @@ /Users/user/Desktop/Git/WuJieCaoJoke/WuJieCaoJoke/ThirdPart/ThirdPlatform/UMeng/umeng_ios_social_sdk_4.2.3_arm64_custom/UMSocial_Sdk_Extra_Frameworks/TencentOpenAPI, ); INFOPLIST_FILE = WZLBadgeDemo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -528,7 +527,7 @@ /Users/user/Desktop/Git/WuJieCaoJoke/WuJieCaoJoke/ThirdPart/ThirdPlatform/UMeng/umeng_ios_social_sdk_4.2.3_arm64_custom/UMSocial_Sdk_Extra_Frameworks/TencentOpenAPI, ); INFOPLIST_FILE = WZLBadgeDemo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", diff --git a/WZLBadgeDemo/Base.lproj/Main.storyboard b/WZLBadgeDemo/Base.lproj/Main.storyboard index b71455b..63358ce 100644 --- a/WZLBadgeDemo/Base.lproj/Main.storyboard +++ b/WZLBadgeDemo/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -10,7 +14,7 @@ - + @@ -30,17 +34,18 @@ - + - + @@ -58,7 +63,7 @@ - + diff --git a/WZLBadgeDemo/ViewController.m b/WZLBadgeDemo/ViewController.m index dc310fb..084ef53 100644 --- a/WZLBadgeDemo/ViewController.m +++ b/WZLBadgeDemo/ViewController.m @@ -63,6 +63,10 @@ - (NSMutableArray *)prepareDataItems btn.tag = 1000; [btn setImage:[UIImage imageNamed:@"logo.jpg"] forState:UIControlStateNormal]; btn.layer.cornerRadius = btn.width / 2; + + if (i == 0) { + btn.badgeRadius = 2; + } if (i == 1) { btn.badgeBgColor = [UIColor purpleColor]; btn.badgeCenterOffset = CGPointMake(-btn.width, 0);