diff --git a/Example/JSBadgeView.xcodeproj/project.pbxproj b/Example/JSBadgeView.xcodeproj/project.pbxproj index 5a640da..0a64d16 100644 --- a/Example/JSBadgeView.xcodeproj/project.pbxproj +++ b/Example/JSBadgeView.xcodeproj/project.pbxproj @@ -206,6 +206,7 @@ 6003F587195388D20070C39A /* Frameworks */, 6003F588195388D20070C39A /* Resources */, 2B276D4DEFA48597D1EAFEA4 /* Copy Pods Resources */, + 1A75C54995B6326D75562D23 /* Embed Pods Frameworks */, ); buildRules = ( ); @@ -225,6 +226,7 @@ 6003F5AB195388D20070C39A /* Frameworks */, 6003F5AC195388D20070C39A /* Resources */, 5AE0D8D1A81A1FC823A57EFA /* Copy Pods Resources */, + 5D77F70A8B319118B80C1472 /* Embed Pods Frameworks */, ); buildRules = ( ); @@ -308,6 +310,21 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; + 1A75C54995B6326D75562D23 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-JSBadgeView/Pods-JSBadgeView-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 2B276D4DEFA48597D1EAFEA4 /* Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -338,6 +355,21 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; showEnvVarsInLog = 0; }; + 5D77F70A8B319118B80C1472 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 7C90B127821C2227416080E0 /* Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/Example/JSBadgeView/JSViewController.m b/Example/JSBadgeView/JSViewController.m index 24e2c76..72957ae 100644 --- a/Example/JSBadgeView/JSViewController.m +++ b/Example/JSBadgeView/JSViewController.m @@ -64,17 +64,19 @@ - (void)loadView { UIView *rectangle = [[UIView alloc] initWithFrame:CGRectIntegral(CGRectMake(xOffset, yOffset, - rectangleBounds.size.width, - rectangleBounds.size.height))]; + rectangleBounds.size.width/3, + rectangleBounds.size.height/3))]; rectangle.backgroundColor = kSquareColor; - rectangle.layer.cornerRadius = kSquareCornerRadius; - rectangle.layer.shadowColor = [UIColor blackColor].CGColor; - rectangle.layer.shadowOffset = CGSizeMake(0.0f, 3.0f); - rectangle.layer.shadowOpacity = 0.4; - rectangle.layer.shadowRadius = 1.0; - rectangle.layer.shadowPath = rectangleShadowPath; +// rectangle.layer.cornerRadius = kSquareCornerRadius; +// rectangle.layer.shadowColor = [UIColor blackColor].CGColor; +// rectangle.layer.shadowOffset = CGSizeMake(0.0f, 3.0f); +// rectangle.layer.shadowOpacity = 0.4; +// rectangle.layer.shadowRadius = 1.0; +// rectangle.layer.shadowPath = rectangleShadowPath; JSBadgeView *badgeView = [[JSBadgeView alloc] initWithParentView:rectangle alignment:JSBadgeViewAlignmentTopRight]; + badgeView.badgeMinWidth = 5; + badgeView.badgeTextFont = [UIFont systemFontOfSize:8]; badgeView.badgeText = [NSString stringWithFormat:@"%d", i]; [scrollView addSubview:rectangle]; diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 1131a77..24cc446 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -17,4 +17,4 @@ SPEC CHECKSUMS: JSBadgeView: 3861ddee41094284d9468e6d0af5107f703aaac5 Specta: 96fe05fe5c7348b5223f85e862904f6e832abb14 -COCOAPODS: 0.37.1 +COCOAPODS: 0.39.0 diff --git a/Pod/Classes/JSBadgeView.m b/Pod/Classes/JSBadgeView.m index e3c5366..fba0d71 100644 --- a/Pod/Classes/JSBadgeView.m +++ b/Pod/Classes/JSBadgeView.m @@ -42,9 +42,9 @@ of this software and associated documentation files (the "Software"), to deal #endif static const CGFloat JSBadgeViewShadowRadius = 1.0f; -static const CGFloat JSBadgeViewHeight = 16.0f; -static const CGFloat JSBadgeViewTextSideMargin = 8.0f; -static const CGFloat JSBadgeViewCornerRadius = 10.0f; +CGFloat JSBadgeViewHeight = 16.0f; +CGFloat JSBadgeViewTextSideMargin = 8.0f; +CGFloat JSBadgeViewCornerRadius = 10.0f; // Thanks to Peter Steinberger: https://gist.github.com/steipete/6526860 static BOOL JSBadgeViewIsUIKitFlatMode(void) @@ -148,6 +148,11 @@ - (void)layoutSubviews const CGFloat textWidth = [self sizeOfTextForCurrentSettings].width; const CGFloat marginToDrawInside = [self marginToDrawInside]; + if (_badgeMinWidth > 0) { + JSBadgeViewTextSideMargin = _badgeMinWidth; + JSBadgeViewHeight = 2*JSBadgeViewTextSideMargin; + JSBadgeViewCornerRadius = JSBadgeViewTextSideMargin + 2; + } const CGFloat viewWidth = MAX(_badgeMinWidth, textWidth + JSBadgeViewTextSideMargin + (marginToDrawInside * 2)); const CGFloat viewHeight = JSBadgeViewHeight + (marginToDrawInside * 2);