Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复badgeRadius设置无效的bug,demo修改了这个属性 测试没问题 #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions WZLBadge/View/UIView+WZLBadge.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions WZLBadgeDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
19AD4E881BB3D4600059AA66 /* UITabBarItem+WZLBadge.h */,
19AD4E891BB3D4600059AA66 /* UITabBarItem+WZLBadge.m */,
);
name = BarItem;
path = BarButtonItem;
path = BarItem;
sourceTree = "<group>";
};
1968600A1B78AB4A00AD10C2 /* View */ = {
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down
21 changes: 13 additions & 8 deletions WZLBadgeDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="nPv-CI-Xkq">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="nPv-CI-Xkq">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="Tpf-1J-NNw">
<objects>
<navigationController id="nPv-CI-Xkq" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Fx2-Ej-wk7">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -30,17 +34,18 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="WZLBadgeDemo" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ySJ-DU-qSP">
<rect key="frame" x="25" y="449" width="207" height="53"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<tabBarItem key="tabBarItem" title="Item1" id="7FX-PP-AfN"/>
<navigationItem key="navigationItem" id="dmp-0O-F8n"/>
Expand All @@ -58,7 +63,7 @@
<tabBar key="tabBar" contentMode="scaleToFill" id="IxV-HF-luf">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FFV-hy-4eO" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
4 changes: 4 additions & 0 deletions WZLBadgeDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down