├── README.md
├── XMBadgeView-Demo.xcodeproj
├── xcuserdata
│ └── shscce.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── XMBadgeView-Demo.xcscheme
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── shscce.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── project.pbxproj
├── XMBadgeView-Demo
├── ViewController.h
├── AppDelegate.h
├── main.m
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── ViewController.m
├── AppDelegate.m
├── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.xib
└── XMBadgeView
│ ├── XMBadgeView.h
│ └── XMBadgeView.m
├── .gitignore
├── XMBadgeView-DemoTests
├── Info.plist
└── XMBadgeView_DemoTests.m
└── LICENSE
/README.md:
--------------------------------------------------------------------------------
1 | #XMBadgeView-Demo
2 | 模仿QQ未读消息的一个badgeView,可以拖动删除
3 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/xcuserdata/shscce.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/project.xcworkspace/xcuserdata/shscce.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ws00801526/XMBadgeView/HEAD/XMBadgeView-Demo.xcodeproj/project.xcworkspace/xcuserdata/shscce.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/XMBadgeView-Demo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/xcuserdata/shscce.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | XMBadgeView-Demo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 93107DB51B43AE7E00AF5D4A
16 |
17 | primary
18 |
19 |
20 | 93107DCE1B43AE7E00AF5D4A
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/XMBadgeView-DemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.xmfraker.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/XMBadgeView-DemoTests/XMBadgeView_DemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMBadgeView_DemoTests.m
3 | // XMBadgeView-DemoTests
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface XMBadgeView_DemoTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation XMBadgeView_DemoTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 fraiker
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/XMBadgeView-Demo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.xmfraker.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | #import "XMBadgeView.h"
12 |
13 | @interface ViewController ()
14 | @property (weak, nonatomic) IBOutlet XMBadgeView *badgeViewFromXib;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view, typically from a nib.
23 |
24 |
25 | //测试 直接从XIB中实例化 badgeView
26 | [self.badgeViewFromXib setBadgeText:@"10"];
27 | [self.badgeViewFromXib setBadgeViewAlignment:XMBadgeViewAlignmentCenterRight];
28 |
29 | //测试 直接addSubView添加到需要显示的父view
30 | XMBadgeView *badge = [[XMBadgeView alloc] initWithFrame:CGRectZero];
31 | [badge setPanable:NO];
32 | [badge setBadgeText:@"99+"];
33 | [badge setBadgeViewAlignment:XMBadgeViewAlignmentCenter];
34 | [self.view addSubview:badge];
35 |
36 |
37 | //测试使用initWithAttachView 添加badgeView
38 | UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(30, 80, 100, 100)];
39 | greenView.userInteractionEnabled = YES;
40 | greenView.backgroundColor = [UIColor greenColor];
41 | [self.view addSubview:greenView];
42 |
43 | XMBadgeView *greenBadgeView = [[XMBadgeView alloc] initWithAttachView:greenView alignment:XMBadgeViewAlignmentTopRight];
44 | [greenBadgeView setBadgeText:@""];
45 |
46 | //测试使用initParentView 添加badgeView
47 | UIView *yellowView = [[UIView alloc] initWithFrame:CGRectMake(30, 200, 120, 120)];
48 | yellowView.backgroundColor = [UIColor yellowColor];
49 | [self.view addSubview:yellowView];
50 |
51 | XMBadgeView *yellowBadgeView = [[XMBadgeView alloc] initWithParentView:yellowView alignment:XMBadgeViewAlignmentCenter];
52 | [yellowBadgeView setPanable:YES];
53 | [yellowBadgeView setBadgeText:@"79"];
54 |
55 | }
56 |
57 | - (void)didReceiveMemoryWarning {
58 | [super didReceiveMemoryWarning];
59 | // Dispose of any resources that can be recreated.
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/xcuserdata/shscce.xcuserdatad/xcschemes/XMBadgeView-Demo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/XMBadgeView/XMBadgeView.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMBadgeView.h
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //枚举类型 规定badgeView位于父View的相对位置 默认TopLeft
12 | typedef NS_ENUM(NSUInteger, XMBadgeViewAlignment)
13 | {
14 | XMBadgeViewAlignmentTopLeft = 0,
15 | XMBadgeViewAlignmentTopRight,
16 | XMBadgeViewAlignmentTopCenter,
17 | XMBadgeViewAlignmentCenter,
18 | XMBadgeViewAlignmentCenterLeft,
19 | XMBadgeViewAlignmentCenterRight,
20 | XMBadgeViewAlignmentBottomLeft,
21 | XMBadgeViewAlignmentBottomRight,
22 | XMBadgeViewAlignmentBottomCenter
23 | };
24 |
25 |
26 | @interface XMBadgeView : UIView
27 |
28 | - (void)reset;
29 |
30 | /**
31 | * 显示文字
32 | */
33 | @property (nonatomic, copy) NSString *badgeText;
34 |
35 |
36 | /**
37 | * XMBadgeView 拖动的最大距离 默认为100
38 | *
39 | * maxDistance of XMBadgeView can pan. Default is 100
40 | */
41 | @property (nonatomic) CGFloat maxDistance;
42 |
43 |
44 | @property (nonatomic) BOOL panable;
45 |
46 | #pragma mark - Customization 自定义外观类型
47 |
48 | /**
49 | * badgeView 位于父View位置 默认TopLeft
50 | */
51 | @property (nonatomic) XMBadgeViewAlignment badgeViewAlignment
52 | UI_APPEARANCE_SELECTOR;
53 |
54 | /**
55 | * XMBadgeView 圆角角度 默认为 self.bounds.width/2
56 | *
57 | * cornerRadius of XMBadgeView.layer. Default is self.bounds.width/2
58 | */
59 | @property (nonatomic) CGFloat badgeViewCornerRadius UI_APPEARANCE_SELECTOR;
60 |
61 | /**
62 | * badge文字颜色 默认为[UIColor whiteColor]
63 | *
64 | * textColor of badgeText. Default is [UIColor whiteColor]
65 | *
66 | */
67 | @property (nonatomic, strong) UIColor *badgeTextColor UI_APPEARANCE_SELECTOR;
68 |
69 | /**
70 | * badge文字字体 默认为[UIFont systemFontOfSize:12.0f]
71 | *
72 | * textFont of badgeText. Default is [UIFont systemFontOfSize:12.0f]
73 | *
74 | */
75 | @property (nonatomic, strong) UIFont *badgeTextFont UI_APPEARANCE_SELECTOR;
76 |
77 | /**
78 | * badge背景色 默认为 [UIColor redColor]
79 | *
80 | * backgroundColor of badgeView. Default is [UIColor redColor]
81 | *
82 | */
83 | @property (nonatomic, strong) UIColor *badgeBackgroundColor UI_APPEARANCE_SELECTOR;
84 |
85 |
86 | /**
87 | * badgeText 阴影大小 默认 CGSizeZero
88 | *
89 | * offset of badgeTextShadow. Default is CGSizeZero
90 | *
91 | */
92 | @property (nonatomic, assign) CGSize badgeTextShadowSize UI_APPEARANCE_SELECTOR;
93 |
94 | /**
95 | * badgeText 阴影颜色 默认 [UIColor whiteColor]
96 | *
97 | * shadowColor of badgeText. Default is [UIColor whiteColor]
98 | *
99 | */
100 | @property (nonatomic, strong) UIColor *badgeTextShadowColor UI_APPEARANCE_SELECTOR;
101 |
102 | /**
103 | * badgeShadowColor badgeView 阴影颜色. 默认透明黑色
104 | *
105 | * Color of the badge shadow. Default is semi-transparent black.
106 | */
107 | @property (nonatomic, strong) UIColor *badgeShadowColor UI_APPEARANCE_SELECTOR;
108 |
109 | /**
110 | * badgeView 阴影大小 默认CGSizeZero.
111 | *
112 | * Offset of the badge shadow. Default is CGSizeZero.
113 | */
114 | @property (nonatomic, assign) CGSize badgeShadowSize UI_APPEARANCE_SELECTOR;
115 |
116 | /**
117 | * badgeView边框宽度 默认0.0f
118 | *
119 | * Width of the circle around the badge. Default is 0.0 points.
120 | */
121 | @property (nonatomic, assign) CGFloat badgeStrokeWidth UI_APPEARANCE_SELECTOR;
122 |
123 | /**
124 | * badgeView边框颜色 默认 [UIColor whiteColor]
125 | *
126 | * Color of the circle around the badge. Default is [UIColor whiteColor].
127 | */
128 | @property (nonatomic, strong) UIColor *badgeStrokeColor UI_APPEARANCE_SELECTOR;
129 |
130 | /**
131 | * badgeView自适应调节X,Y轴位置
132 | *
133 | * Allows to shift the badge by x and y points.
134 | */
135 | @property (nonatomic, assign) CGPoint badgePositionAdjustment UI_APPEARANCE_SELECTOR;
136 |
137 | /**
138 | *
139 | * BadgeView 最小宽度,避免使用过小字体时 badgeView过小 默认18.0f
140 | *
141 | * The minimum width of a badge circle. We need this to avoid elipse shapes when using small fonts. Default is 18.0f
142 | */
143 | @property (nonatomic, assign) CGFloat badgeMinWidth UI_APPEARANCE_SELECTOR;
144 |
145 |
146 | /**
147 | * 实例化一个XMBadgeView
148 | *
149 | * @param parentView 显示XMBadgeView的父View
150 | * @param alignment
151 | *
152 | * 使用此方法,默认XMBadgeView不可拖动删除
153 | *
154 | * FIXME 重新设置panable=YES 可以打开 ,但是有bug,如果badgeView位于四周会导致只有处于父view四周,会导致只有父类view内部的badgeView具有点击效果,超出父类的无法拖动,本人无法解决
155 | * @return 一个XMBadgeView实例
156 | */
157 | - (instancetype)initWithParentView:(UIView *)parentView alignment:(XMBadgeViewAlignment)alignment;
158 |
159 | /**
160 | * 实例化一个XMBadgeView
161 | *
162 | * @param attachView 依附的view
163 | * @param alignment 依附view的相对位置
164 | *
165 | * 使用此方法默认XMBadgeView可以拖动删除
166 | * @return 一个XMBadgeView实例
167 | */
168 | - (instancetype)initWithAttachView:(UIView *)attachView alignment:(XMBadgeViewAlignment)alignment;
169 | @end
170 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 93107DBC1B43AE7E00AF5D4A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93107DBB1B43AE7E00AF5D4A /* main.m */; };
11 | 93107DBF1B43AE7E00AF5D4A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93107DBE1B43AE7E00AF5D4A /* AppDelegate.m */; };
12 | 93107DC21B43AE7E00AF5D4A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93107DC11B43AE7E00AF5D4A /* ViewController.m */; };
13 | 93107DC51B43AE7E00AF5D4A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 93107DC31B43AE7E00AF5D4A /* Main.storyboard */; };
14 | 93107DC71B43AE7E00AF5D4A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93107DC61B43AE7E00AF5D4A /* Images.xcassets */; };
15 | 93107DCA1B43AE7E00AF5D4A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93107DC81B43AE7E00AF5D4A /* LaunchScreen.xib */; };
16 | 93107DD61B43AE7E00AF5D4A /* XMBadgeView_DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 93107DD51B43AE7E00AF5D4A /* XMBadgeView_DemoTests.m */; };
17 | 93107DE21B43B0A400AF5D4A /* XMBadgeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 93107DE11B43B0A400AF5D4A /* XMBadgeView.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXContainerItemProxy section */
21 | 93107DD01B43AE7E00AF5D4A /* PBXContainerItemProxy */ = {
22 | isa = PBXContainerItemProxy;
23 | containerPortal = 93107DAE1B43AE7E00AF5D4A /* Project object */;
24 | proxyType = 1;
25 | remoteGlobalIDString = 93107DB51B43AE7E00AF5D4A;
26 | remoteInfo = "XMBadgeView-Demo";
27 | };
28 | /* End PBXContainerItemProxy section */
29 |
30 | /* Begin PBXFileReference section */
31 | 93107DB61B43AE7E00AF5D4A /* XMBadgeView-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "XMBadgeView-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
32 | 93107DBA1B43AE7E00AF5D4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
33 | 93107DBB1B43AE7E00AF5D4A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
34 | 93107DBD1B43AE7E00AF5D4A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
35 | 93107DBE1B43AE7E00AF5D4A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
36 | 93107DC01B43AE7E00AF5D4A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
37 | 93107DC11B43AE7E00AF5D4A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
38 | 93107DC41B43AE7E00AF5D4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
39 | 93107DC61B43AE7E00AF5D4A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
40 | 93107DC91B43AE7E00AF5D4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
41 | 93107DCF1B43AE7E00AF5D4A /* XMBadgeView-DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "XMBadgeView-DemoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
42 | 93107DD41B43AE7E00AF5D4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
43 | 93107DD51B43AE7E00AF5D4A /* XMBadgeView_DemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XMBadgeView_DemoTests.m; sourceTree = ""; };
44 | 93107DE01B43B0A400AF5D4A /* XMBadgeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMBadgeView.h; sourceTree = ""; };
45 | 93107DE11B43B0A400AF5D4A /* XMBadgeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMBadgeView.m; sourceTree = ""; };
46 | /* End PBXFileReference section */
47 |
48 | /* Begin PBXFrameworksBuildPhase section */
49 | 93107DB31B43AE7E00AF5D4A /* Frameworks */ = {
50 | isa = PBXFrameworksBuildPhase;
51 | buildActionMask = 2147483647;
52 | files = (
53 | );
54 | runOnlyForDeploymentPostprocessing = 0;
55 | };
56 | 93107DCC1B43AE7E00AF5D4A /* Frameworks */ = {
57 | isa = PBXFrameworksBuildPhase;
58 | buildActionMask = 2147483647;
59 | files = (
60 | );
61 | runOnlyForDeploymentPostprocessing = 0;
62 | };
63 | /* End PBXFrameworksBuildPhase section */
64 |
65 | /* Begin PBXGroup section */
66 | 93107DAD1B43AE7E00AF5D4A = {
67 | isa = PBXGroup;
68 | children = (
69 | 93107DB81B43AE7E00AF5D4A /* XMBadgeView-Demo */,
70 | 93107DD21B43AE7E00AF5D4A /* XMBadgeView-DemoTests */,
71 | 93107DB71B43AE7E00AF5D4A /* Products */,
72 | );
73 | sourceTree = "";
74 | };
75 | 93107DB71B43AE7E00AF5D4A /* Products */ = {
76 | isa = PBXGroup;
77 | children = (
78 | 93107DB61B43AE7E00AF5D4A /* XMBadgeView-Demo.app */,
79 | 93107DCF1B43AE7E00AF5D4A /* XMBadgeView-DemoTests.xctest */,
80 | );
81 | name = Products;
82 | sourceTree = "";
83 | };
84 | 93107DB81B43AE7E00AF5D4A /* XMBadgeView-Demo */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 93107DDF1B43AE9B00AF5D4A /* XMBadgeView */,
88 | 93107DBD1B43AE7E00AF5D4A /* AppDelegate.h */,
89 | 93107DBE1B43AE7E00AF5D4A /* AppDelegate.m */,
90 | 93107DC01B43AE7E00AF5D4A /* ViewController.h */,
91 | 93107DC11B43AE7E00AF5D4A /* ViewController.m */,
92 | 93107DC31B43AE7E00AF5D4A /* Main.storyboard */,
93 | 93107DC61B43AE7E00AF5D4A /* Images.xcassets */,
94 | 93107DC81B43AE7E00AF5D4A /* LaunchScreen.xib */,
95 | 93107DB91B43AE7E00AF5D4A /* Supporting Files */,
96 | );
97 | path = "XMBadgeView-Demo";
98 | sourceTree = "";
99 | };
100 | 93107DB91B43AE7E00AF5D4A /* Supporting Files */ = {
101 | isa = PBXGroup;
102 | children = (
103 | 93107DBA1B43AE7E00AF5D4A /* Info.plist */,
104 | 93107DBB1B43AE7E00AF5D4A /* main.m */,
105 | );
106 | name = "Supporting Files";
107 | sourceTree = "";
108 | };
109 | 93107DD21B43AE7E00AF5D4A /* XMBadgeView-DemoTests */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 93107DD51B43AE7E00AF5D4A /* XMBadgeView_DemoTests.m */,
113 | 93107DD31B43AE7E00AF5D4A /* Supporting Files */,
114 | );
115 | path = "XMBadgeView-DemoTests";
116 | sourceTree = "";
117 | };
118 | 93107DD31B43AE7E00AF5D4A /* Supporting Files */ = {
119 | isa = PBXGroup;
120 | children = (
121 | 93107DD41B43AE7E00AF5D4A /* Info.plist */,
122 | );
123 | name = "Supporting Files";
124 | sourceTree = "";
125 | };
126 | 93107DDF1B43AE9B00AF5D4A /* XMBadgeView */ = {
127 | isa = PBXGroup;
128 | children = (
129 | 93107DE01B43B0A400AF5D4A /* XMBadgeView.h */,
130 | 93107DE11B43B0A400AF5D4A /* XMBadgeView.m */,
131 | );
132 | path = XMBadgeView;
133 | sourceTree = "";
134 | };
135 | /* End PBXGroup section */
136 |
137 | /* Begin PBXNativeTarget section */
138 | 93107DB51B43AE7E00AF5D4A /* XMBadgeView-Demo */ = {
139 | isa = PBXNativeTarget;
140 | buildConfigurationList = 93107DD91B43AE7E00AF5D4A /* Build configuration list for PBXNativeTarget "XMBadgeView-Demo" */;
141 | buildPhases = (
142 | 93107DB21B43AE7E00AF5D4A /* Sources */,
143 | 93107DB31B43AE7E00AF5D4A /* Frameworks */,
144 | 93107DB41B43AE7E00AF5D4A /* Resources */,
145 | );
146 | buildRules = (
147 | );
148 | dependencies = (
149 | );
150 | name = "XMBadgeView-Demo";
151 | productName = "XMBadgeView-Demo";
152 | productReference = 93107DB61B43AE7E00AF5D4A /* XMBadgeView-Demo.app */;
153 | productType = "com.apple.product-type.application";
154 | };
155 | 93107DCE1B43AE7E00AF5D4A /* XMBadgeView-DemoTests */ = {
156 | isa = PBXNativeTarget;
157 | buildConfigurationList = 93107DDC1B43AE7E00AF5D4A /* Build configuration list for PBXNativeTarget "XMBadgeView-DemoTests" */;
158 | buildPhases = (
159 | 93107DCB1B43AE7E00AF5D4A /* Sources */,
160 | 93107DCC1B43AE7E00AF5D4A /* Frameworks */,
161 | 93107DCD1B43AE7E00AF5D4A /* Resources */,
162 | );
163 | buildRules = (
164 | );
165 | dependencies = (
166 | 93107DD11B43AE7E00AF5D4A /* PBXTargetDependency */,
167 | );
168 | name = "XMBadgeView-DemoTests";
169 | productName = "XMBadgeView-DemoTests";
170 | productReference = 93107DCF1B43AE7E00AF5D4A /* XMBadgeView-DemoTests.xctest */;
171 | productType = "com.apple.product-type.bundle.unit-test";
172 | };
173 | /* End PBXNativeTarget section */
174 |
175 | /* Begin PBXProject section */
176 | 93107DAE1B43AE7E00AF5D4A /* Project object */ = {
177 | isa = PBXProject;
178 | attributes = {
179 | LastUpgradeCheck = 0630;
180 | ORGANIZATIONNAME = xmfraker;
181 | TargetAttributes = {
182 | 93107DB51B43AE7E00AF5D4A = {
183 | CreatedOnToolsVersion = 6.3.2;
184 | };
185 | 93107DCE1B43AE7E00AF5D4A = {
186 | CreatedOnToolsVersion = 6.3.2;
187 | TestTargetID = 93107DB51B43AE7E00AF5D4A;
188 | };
189 | };
190 | };
191 | buildConfigurationList = 93107DB11B43AE7E00AF5D4A /* Build configuration list for PBXProject "XMBadgeView-Demo" */;
192 | compatibilityVersion = "Xcode 3.2";
193 | developmentRegion = English;
194 | hasScannedForEncodings = 0;
195 | knownRegions = (
196 | en,
197 | Base,
198 | );
199 | mainGroup = 93107DAD1B43AE7E00AF5D4A;
200 | productRefGroup = 93107DB71B43AE7E00AF5D4A /* Products */;
201 | projectDirPath = "";
202 | projectRoot = "";
203 | targets = (
204 | 93107DB51B43AE7E00AF5D4A /* XMBadgeView-Demo */,
205 | 93107DCE1B43AE7E00AF5D4A /* XMBadgeView-DemoTests */,
206 | );
207 | };
208 | /* End PBXProject section */
209 |
210 | /* Begin PBXResourcesBuildPhase section */
211 | 93107DB41B43AE7E00AF5D4A /* Resources */ = {
212 | isa = PBXResourcesBuildPhase;
213 | buildActionMask = 2147483647;
214 | files = (
215 | 93107DC51B43AE7E00AF5D4A /* Main.storyboard in Resources */,
216 | 93107DCA1B43AE7E00AF5D4A /* LaunchScreen.xib in Resources */,
217 | 93107DC71B43AE7E00AF5D4A /* Images.xcassets in Resources */,
218 | );
219 | runOnlyForDeploymentPostprocessing = 0;
220 | };
221 | 93107DCD1B43AE7E00AF5D4A /* Resources */ = {
222 | isa = PBXResourcesBuildPhase;
223 | buildActionMask = 2147483647;
224 | files = (
225 | );
226 | runOnlyForDeploymentPostprocessing = 0;
227 | };
228 | /* End PBXResourcesBuildPhase section */
229 |
230 | /* Begin PBXSourcesBuildPhase section */
231 | 93107DB21B43AE7E00AF5D4A /* Sources */ = {
232 | isa = PBXSourcesBuildPhase;
233 | buildActionMask = 2147483647;
234 | files = (
235 | 93107DC21B43AE7E00AF5D4A /* ViewController.m in Sources */,
236 | 93107DBF1B43AE7E00AF5D4A /* AppDelegate.m in Sources */,
237 | 93107DBC1B43AE7E00AF5D4A /* main.m in Sources */,
238 | 93107DE21B43B0A400AF5D4A /* XMBadgeView.m in Sources */,
239 | );
240 | runOnlyForDeploymentPostprocessing = 0;
241 | };
242 | 93107DCB1B43AE7E00AF5D4A /* Sources */ = {
243 | isa = PBXSourcesBuildPhase;
244 | buildActionMask = 2147483647;
245 | files = (
246 | 93107DD61B43AE7E00AF5D4A /* XMBadgeView_DemoTests.m in Sources */,
247 | );
248 | runOnlyForDeploymentPostprocessing = 0;
249 | };
250 | /* End PBXSourcesBuildPhase section */
251 |
252 | /* Begin PBXTargetDependency section */
253 | 93107DD11B43AE7E00AF5D4A /* PBXTargetDependency */ = {
254 | isa = PBXTargetDependency;
255 | target = 93107DB51B43AE7E00AF5D4A /* XMBadgeView-Demo */;
256 | targetProxy = 93107DD01B43AE7E00AF5D4A /* PBXContainerItemProxy */;
257 | };
258 | /* End PBXTargetDependency section */
259 |
260 | /* Begin PBXVariantGroup section */
261 | 93107DC31B43AE7E00AF5D4A /* Main.storyboard */ = {
262 | isa = PBXVariantGroup;
263 | children = (
264 | 93107DC41B43AE7E00AF5D4A /* Base */,
265 | );
266 | name = Main.storyboard;
267 | sourceTree = "";
268 | };
269 | 93107DC81B43AE7E00AF5D4A /* LaunchScreen.xib */ = {
270 | isa = PBXVariantGroup;
271 | children = (
272 | 93107DC91B43AE7E00AF5D4A /* Base */,
273 | );
274 | name = LaunchScreen.xib;
275 | sourceTree = "";
276 | };
277 | /* End PBXVariantGroup section */
278 |
279 | /* Begin XCBuildConfiguration section */
280 | 93107DD71B43AE7E00AF5D4A /* Debug */ = {
281 | isa = XCBuildConfiguration;
282 | buildSettings = {
283 | ALWAYS_SEARCH_USER_PATHS = NO;
284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
285 | CLANG_CXX_LIBRARY = "libc++";
286 | CLANG_ENABLE_MODULES = YES;
287 | CLANG_ENABLE_OBJC_ARC = YES;
288 | CLANG_WARN_BOOL_CONVERSION = YES;
289 | CLANG_WARN_CONSTANT_CONVERSION = YES;
290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
291 | CLANG_WARN_EMPTY_BODY = YES;
292 | CLANG_WARN_ENUM_CONVERSION = YES;
293 | CLANG_WARN_INT_CONVERSION = YES;
294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
295 | CLANG_WARN_UNREACHABLE_CODE = YES;
296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
298 | COPY_PHASE_STRIP = NO;
299 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
300 | ENABLE_STRICT_OBJC_MSGSEND = YES;
301 | GCC_C_LANGUAGE_STANDARD = gnu99;
302 | GCC_DYNAMIC_NO_PIC = NO;
303 | GCC_NO_COMMON_BLOCKS = YES;
304 | GCC_OPTIMIZATION_LEVEL = 0;
305 | GCC_PREPROCESSOR_DEFINITIONS = (
306 | "DEBUG=1",
307 | "$(inherited)",
308 | );
309 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
312 | GCC_WARN_UNDECLARED_SELECTOR = YES;
313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
314 | GCC_WARN_UNUSED_FUNCTION = YES;
315 | GCC_WARN_UNUSED_VARIABLE = YES;
316 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
317 | MTL_ENABLE_DEBUG_INFO = YES;
318 | ONLY_ACTIVE_ARCH = YES;
319 | SDKROOT = iphoneos;
320 | };
321 | name = Debug;
322 | };
323 | 93107DD81B43AE7E00AF5D4A /* Release */ = {
324 | isa = XCBuildConfiguration;
325 | buildSettings = {
326 | ALWAYS_SEARCH_USER_PATHS = NO;
327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
328 | CLANG_CXX_LIBRARY = "libc++";
329 | CLANG_ENABLE_MODULES = YES;
330 | CLANG_ENABLE_OBJC_ARC = YES;
331 | CLANG_WARN_BOOL_CONVERSION = YES;
332 | CLANG_WARN_CONSTANT_CONVERSION = YES;
333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
334 | CLANG_WARN_EMPTY_BODY = YES;
335 | CLANG_WARN_ENUM_CONVERSION = YES;
336 | CLANG_WARN_INT_CONVERSION = YES;
337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
338 | CLANG_WARN_UNREACHABLE_CODE = YES;
339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
340 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
341 | COPY_PHASE_STRIP = NO;
342 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
343 | ENABLE_NS_ASSERTIONS = NO;
344 | ENABLE_STRICT_OBJC_MSGSEND = YES;
345 | GCC_C_LANGUAGE_STANDARD = gnu99;
346 | GCC_NO_COMMON_BLOCKS = YES;
347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
349 | GCC_WARN_UNDECLARED_SELECTOR = YES;
350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
351 | GCC_WARN_UNUSED_FUNCTION = YES;
352 | GCC_WARN_UNUSED_VARIABLE = YES;
353 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
354 | MTL_ENABLE_DEBUG_INFO = NO;
355 | SDKROOT = iphoneos;
356 | VALIDATE_PRODUCT = YES;
357 | };
358 | name = Release;
359 | };
360 | 93107DDA1B43AE7E00AF5D4A /* Debug */ = {
361 | isa = XCBuildConfiguration;
362 | buildSettings = {
363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
364 | INFOPLIST_FILE = "XMBadgeView-Demo/Info.plist";
365 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
366 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
367 | PRODUCT_NAME = "$(TARGET_NAME)";
368 | };
369 | name = Debug;
370 | };
371 | 93107DDB1B43AE7E00AF5D4A /* Release */ = {
372 | isa = XCBuildConfiguration;
373 | buildSettings = {
374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
375 | INFOPLIST_FILE = "XMBadgeView-Demo/Info.plist";
376 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
378 | PRODUCT_NAME = "$(TARGET_NAME)";
379 | };
380 | name = Release;
381 | };
382 | 93107DDD1B43AE7E00AF5D4A /* Debug */ = {
383 | isa = XCBuildConfiguration;
384 | buildSettings = {
385 | BUNDLE_LOADER = "$(TEST_HOST)";
386 | FRAMEWORK_SEARCH_PATHS = (
387 | "$(SDKROOT)/Developer/Library/Frameworks",
388 | "$(inherited)",
389 | );
390 | GCC_PREPROCESSOR_DEFINITIONS = (
391 | "DEBUG=1",
392 | "$(inherited)",
393 | );
394 | INFOPLIST_FILE = "XMBadgeView-DemoTests/Info.plist";
395 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
396 | PRODUCT_NAME = "$(TARGET_NAME)";
397 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XMBadgeView-Demo.app/XMBadgeView-Demo";
398 | };
399 | name = Debug;
400 | };
401 | 93107DDE1B43AE7E00AF5D4A /* Release */ = {
402 | isa = XCBuildConfiguration;
403 | buildSettings = {
404 | BUNDLE_LOADER = "$(TEST_HOST)";
405 | FRAMEWORK_SEARCH_PATHS = (
406 | "$(SDKROOT)/Developer/Library/Frameworks",
407 | "$(inherited)",
408 | );
409 | INFOPLIST_FILE = "XMBadgeView-DemoTests/Info.plist";
410 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
411 | PRODUCT_NAME = "$(TARGET_NAME)";
412 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XMBadgeView-Demo.app/XMBadgeView-Demo";
413 | };
414 | name = Release;
415 | };
416 | /* End XCBuildConfiguration section */
417 |
418 | /* Begin XCConfigurationList section */
419 | 93107DB11B43AE7E00AF5D4A /* Build configuration list for PBXProject "XMBadgeView-Demo" */ = {
420 | isa = XCConfigurationList;
421 | buildConfigurations = (
422 | 93107DD71B43AE7E00AF5D4A /* Debug */,
423 | 93107DD81B43AE7E00AF5D4A /* Release */,
424 | );
425 | defaultConfigurationIsVisible = 0;
426 | defaultConfigurationName = Release;
427 | };
428 | 93107DD91B43AE7E00AF5D4A /* Build configuration list for PBXNativeTarget "XMBadgeView-Demo" */ = {
429 | isa = XCConfigurationList;
430 | buildConfigurations = (
431 | 93107DDA1B43AE7E00AF5D4A /* Debug */,
432 | 93107DDB1B43AE7E00AF5D4A /* Release */,
433 | );
434 | defaultConfigurationIsVisible = 0;
435 | };
436 | 93107DDC1B43AE7E00AF5D4A /* Build configuration list for PBXNativeTarget "XMBadgeView-DemoTests" */ = {
437 | isa = XCConfigurationList;
438 | buildConfigurations = (
439 | 93107DDD1B43AE7E00AF5D4A /* Debug */,
440 | 93107DDE1B43AE7E00AF5D4A /* Release */,
441 | );
442 | defaultConfigurationIsVisible = 0;
443 | };
444 | /* End XCConfigurationList section */
445 | };
446 | rootObject = 93107DAE1B43AE7E00AF5D4A /* Project object */;
447 | }
448 |
--------------------------------------------------------------------------------
/XMBadgeView-Demo/XMBadgeView/XMBadgeView.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMBadgeView.m
3 | // XMBadgeView-Demo
4 | //
5 | // Created by shscce on 15/7/1.
6 | // Copyright (c) 2015年 xmfraker. All rights reserved.
7 | //
8 |
9 | #import "XMBadgeView.h"
10 |
11 | #import
12 | #include
13 |
14 | #if !__has_feature(objc_arc)
15 | #error XMBadgeView must be compiled with ARC.
16 | #endif
17 |
18 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
19 | #error XMBadgeView only support IOS7+
20 | #endif
21 |
22 | // Silencing some deprecation warnings if your deployment target is iOS7 that can only be fixed by using methods that
23 | // Are only available on iOS7.
24 | // Soon JSBadgeView will require iOS 7 and we'll be able to use the new methods.
25 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
26 | #define XMBadgeViewSilenceDeprecatedMethodStart() _Pragma("clang diagnostic push") \
27 | _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
28 | #define XMBadgeViewSilenceDeprecatedMethodEnd() _Pragma("clang diagnostic pop")
29 | #else
30 | #define XMBadgeViewSilenceDeprecatedMethodStart()
31 | #define XMBadgeViewSilenceDeprecatedMethodEnd()
32 | #endif
33 |
34 | /**
35 | * 默认XMBadgeView 阴影的圆角值
36 | */
37 | static const CGFloat XMBadgeViewShadowRadius = 1.0f;
38 |
39 | /**
40 | * 默认的XMBadgeView的高度
41 | */
42 | static const CGFloat XMBadgeViewHeight = 16.0f;
43 |
44 | /**
45 | * 默认的XMBadgeView文字距离左右两侧边距
46 | */
47 | static const CGFloat XMBadgeViewTextSideMargin = 8.0f;
48 |
49 | @interface XMBadgeView ()
50 |
51 | @property (strong, nonatomic) CAShapeLayer *shapeLayer;
52 | @property (strong, nonatomic) UIView *smallBadgeView;
53 | @property (weak, nonatomic) UIView *attachView;
54 |
55 | @end
56 |
57 | @implementation XMBadgeView
58 |
59 | + (void)applyIOS7Style
60 | {
61 | XMBadgeView *badgeViewAppearanceProxy = XMBadgeView.appearance;
62 |
63 |
64 |
65 | badgeViewAppearanceProxy.badgeTextColor = [UIColor whiteColor];
66 | badgeViewAppearanceProxy.badgeTextFont = [UIFont systemFontOfSize:12.0f];
67 | badgeViewAppearanceProxy.badgeBackgroundColor = [UIColor redColor];
68 | badgeViewAppearanceProxy.badgeShadowSize = CGSizeZero;
69 | badgeViewAppearanceProxy.badgeShadowColor = UIColor.clearColor;
70 | badgeViewAppearanceProxy.badgeTextShadowColor = UIColor.clearColor;
71 | badgeViewAppearanceProxy.badgeTextShadowSize = CGSizeZero;
72 |
73 | badgeViewAppearanceProxy.badgeStrokeWidth = 0.0f;
74 | badgeViewAppearanceProxy.badgeStrokeColor = badgeViewAppearanceProxy.badgeBackgroundColor;
75 |
76 | badgeViewAppearanceProxy.badgeMinWidth = 18.0f;
77 |
78 | badgeViewAppearanceProxy.backgroundColor = [UIColor clearColor];
79 | }
80 |
81 |
82 | + (void)initialize
83 | {
84 | if (self == XMBadgeView.class)
85 | {
86 | [self applyIOS7Style];
87 |
88 | }
89 | }
90 |
91 | #pragma mark - Life Cycle
92 |
93 | - (instancetype)initWithFrame:(CGRect)frame{
94 | if (self = [super initWithFrame:frame]) {
95 | [self setUp];
96 | }
97 | return self;
98 | }
99 |
100 |
101 | - (instancetype)initWithParentView:(UIView *)parentView alignment:(XMBadgeViewAlignment)alignment
102 | {
103 | if ((self = [self initWithFrame:CGRectZero]))
104 | {
105 | self.badgeViewAlignment = alignment;
106 | self.panable = NO;
107 | [parentView addSubview:self];
108 | }
109 |
110 | return self;
111 | }
112 |
113 |
114 | - (instancetype)initWithAttachView:(UIView *)attachView alignment:(XMBadgeViewAlignment)alignment{
115 | if ((self = [self initWithFrame:CGRectZero])) {
116 | self.badgeViewAlignment = alignment;
117 | self.attachView = attachView;
118 | self.panable = YES;
119 |
120 | [self.attachView.superview insertSubview:self aboveSubview:self.attachView];
121 | }
122 | return self;
123 | }
124 |
125 | - (void)awakeFromNib{
126 | [self setUp];
127 | }
128 |
129 | #pragma mark - Layout
130 |
131 | - (CGFloat)marginToDrawInside
132 | {
133 | return self.badgeStrokeWidth * 2.0;
134 | }
135 |
136 | - (void)layoutSubviews
137 | {
138 | [super layoutSubviews];
139 |
140 | CGRect newFrame = self.frame;
141 | const CGFloat textWidth = [self sizeOfTextForCurrentSettings].width;
142 | const CGFloat textHeight = [self sizeOfTextForCurrentSettings].height;
143 | const CGFloat marginToDrawInside = [self marginToDrawInside];
144 | const CGFloat viewWidth = MAX(self.badgeMinWidth, textWidth + XMBadgeViewTextSideMargin + (marginToDrawInside * 2));
145 | const CGFloat viewHeight = MAX(self.badgeMinWidth, textHeight + (marginToDrawInside * 2));
146 | newFrame.size.width = MAX(viewWidth, viewHeight);
147 | newFrame.size.height = MAX(viewWidth, viewHeight);
148 |
149 | //判断是否有依附view 计算坐标方式不同
150 | if (self.attachView) {
151 | CGPoint newCenter = self.center;
152 | CGRect attachViewRect = self.attachView.frame;
153 |
154 | switch (self.badgeViewAlignment) {
155 | case XMBadgeViewAlignmentTopLeft:
156 | newCenter.x = attachViewRect.origin.x;
157 | newCenter.y = attachViewRect.origin.y;
158 | break;
159 | case XMBadgeViewAlignmentTopRight:
160 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width;
161 | newCenter.y = attachViewRect.origin.y;
162 | break;
163 | case XMBadgeViewAlignmentTopCenter:
164 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width/2;
165 | newCenter.y = attachViewRect.origin.y;
166 | break;
167 | case XMBadgeViewAlignmentCenterLeft:
168 | newCenter.x = attachViewRect.origin.x;
169 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height/2;
170 | break;
171 | case XMBadgeViewAlignmentCenterRight:
172 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width;
173 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height/2;
174 | break;
175 | case XMBadgeViewAlignmentBottomLeft:
176 | newCenter.x = attachViewRect.origin.x;
177 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height;
178 | break;
179 | case XMBadgeViewAlignmentBottomRight:
180 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width;
181 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height;
182 | break;
183 | case XMBadgeViewAlignmentBottomCenter:
184 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width/2;
185 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height;
186 | break;
187 | case XMBadgeViewAlignmentCenter:
188 | newCenter.x = attachViewRect.origin.x + attachViewRect.size.width/2;
189 | newCenter.y = attachViewRect.origin.y + attachViewRect.size.height/2;
190 | break;
191 | default:
192 | NSAssert(NO, @"Unimplemented XMBadgeAligment type %lul", (unsigned long)self.badgeViewAlignment);
193 | }
194 |
195 | newCenter.x += _badgePositionAdjustment.x;
196 | newCenter.y += _badgePositionAdjustment.y;
197 |
198 | // Do not set frame directly so we do not interfere with any potential transform set on the view.
199 | self.bounds = CGRectIntegral(CGRectMake(0, 0, CGRectGetWidth(newFrame), CGRectGetHeight(newFrame)));
200 | self.center = newCenter;
201 |
202 | }else{
203 |
204 | const CGRect superviewBounds = self.superview.bounds;
205 | const CGFloat superviewWidth = superviewBounds.size.width;
206 | const CGFloat superviewHeight = superviewBounds.size.height;
207 |
208 | switch (self.badgeViewAlignment) {
209 | case XMBadgeViewAlignmentTopLeft:
210 | newFrame.origin.x = -viewWidth / 2.0f;
211 | newFrame.origin.y = -viewHeight / 2.0f;
212 | break;
213 | case XMBadgeViewAlignmentTopRight:
214 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
215 | newFrame.origin.y = -viewHeight / 2.0f;
216 | break;
217 | case XMBadgeViewAlignmentTopCenter:
218 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
219 | newFrame.origin.y = -viewHeight / 2.0f;
220 | break;
221 | case XMBadgeViewAlignmentCenterLeft:
222 | newFrame.origin.x = -viewWidth / 2.0f;
223 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
224 | break;
225 | case XMBadgeViewAlignmentCenterRight:
226 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
227 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
228 | break;
229 | case XMBadgeViewAlignmentBottomLeft:
230 | newFrame.origin.x = -viewWidth / 2.0f;
231 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
232 | break;
233 | case XMBadgeViewAlignmentBottomRight:
234 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
235 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
236 | break;
237 | case XMBadgeViewAlignmentBottomCenter:
238 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
239 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
240 | break;
241 | case XMBadgeViewAlignmentCenter:
242 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
243 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
244 | break;
245 | default:
246 | NSAssert(NO, @"Unimplemented XMBadgeAligment type %lul", (unsigned long)self.badgeViewAlignment);
247 | }
248 |
249 | newFrame.origin.x += _badgePositionAdjustment.x;
250 | newFrame.origin.y += _badgePositionAdjustment.y;
251 |
252 | // Do not set frame directly so we do not interfere with any potential transform set on the view.
253 | self.bounds = CGRectIntegral(CGRectMake(0, 0, CGRectGetWidth(newFrame), CGRectGetHeight(newFrame)));
254 | self.center = CGPointMake(ceilf(CGRectGetMidX(newFrame)), ceilf(CGRectGetMidY(newFrame)));
255 |
256 | }
257 |
258 | CGRect smallCircleRect = CGRectMake(0, 0, self.badgeViewCornerRadius * (2 - 0.5) , self.badgeViewCornerRadius * (2 - 0.5));
259 | self.smallBadgeView.bounds = smallCircleRect;
260 | self.smallBadgeView.center = self.center;
261 | self.smallBadgeView.layer.cornerRadius = _smallBadgeView.bounds.size.width/2;
262 |
263 | [self setNeedsDisplay];
264 | }
265 |
266 | /*
267 | * Use it When initWithParentView
268 | /
269 | - (void)layoutSubviews
270 | {
271 | [super layoutSubviews];
272 |
273 | CGRect newFrame = self.frame;
274 | const CGRect superviewBounds = self.superview.bounds;
275 |
276 | const CGFloat textWidth = [self.badgeText sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f]}].width;
277 |
278 | const CGFloat marginToDrawInside = [self marginToDrawInside];
279 | const CGFloat viewWidth = MAX(_badgeMinWidth, textWidth + XMBadgeViewTextSideMargin + (marginToDrawInside * 2));
280 | const CGFloat viewHeight = XMBadgeViewHeight + (marginToDrawInside * 2);
281 |
282 | const CGFloat superviewWidth = superviewBounds.size.width;
283 | const CGFloat superviewHeight = superviewBounds.size.height;
284 |
285 | newFrame.size.width = MAX(viewWidth, viewHeight);
286 | newFrame.size.height = MAX(viewWidth, viewHeight);
287 |
288 | switch (self.badgeViewAlignment) {
289 | case XMBadgeViewAlignmentTopLeft:
290 | newFrame.origin.x = -viewWidth / 2.0f;
291 | newFrame.origin.y = -viewHeight / 2.0f;
292 | break;
293 | case XMBadgeViewAlignmentTopRight:
294 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
295 | newFrame.origin.y = -viewHeight / 2.0f;
296 | break;
297 | case XMBadgeViewAlignmentTopCenter:
298 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
299 | newFrame.origin.y = -viewHeight / 2.0f;
300 | break;
301 | case XMBadgeViewAlignmentCenterLeft:
302 | newFrame.origin.x = -viewWidth / 2.0f;
303 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
304 | break;
305 | case XMBadgeViewAlignmentCenterRight:
306 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
307 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
308 | break;
309 | case XMBadgeViewAlignmentBottomLeft:
310 | newFrame.origin.x = -viewWidth / 2.0f;
311 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
312 | break;
313 | case XMBadgeViewAlignmentBottomRight:
314 | newFrame.origin.x = superviewWidth - (viewWidth / 2.0f);
315 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
316 | break;
317 | case XMBadgeViewAlignmentBottomCenter:
318 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
319 | newFrame.origin.y = superviewHeight - (viewHeight / 2.0f);
320 | break;
321 | case XMBadgeViewAlignmentCenter:
322 | newFrame.origin.x = (superviewWidth - viewWidth) / 2.0f;
323 | newFrame.origin.y = (superviewHeight - viewHeight) / 2.0f;
324 | break;
325 | default:
326 | NSAssert(NO, @"Unimplemented XMBadgeAligment type %lul", (unsigned long)self.badgeViewAlignment);
327 | }
328 |
329 | newFrame.origin.x += _badgePositionAdjustment.x;
330 | newFrame.origin.y += _badgePositionAdjustment.y;
331 |
332 | // Do not set frame directly so we do not interfere with any potential transform set on the view.
333 | self.bounds = CGRectIntegral(CGRectMake(0, 0, CGRectGetWidth(newFrame), CGRectGetHeight(newFrame)));
334 | self.center = CGPointMake(ceilf(CGRectGetMidX(newFrame)), ceilf(CGRectGetMidY(newFrame)));
335 |
336 | CGRect smallCircleRect = CGRectMake(0, 0, self.badgeViewCornerRadius * (2 - 0.5) , self.badgeViewCornerRadius * (2 - 0.5));
337 | self.smallBadgeView.bounds = smallCircleRect;
338 | self.smallBadgeView.center = self.center;
339 | self.smallBadgeView.layer.cornerRadius = _smallBadgeView.bounds.size.width/2;
340 |
341 |
342 | [self setNeedsDisplay];
343 | }
344 | */
345 |
346 |
347 | #pragma mark - Drawing
348 |
349 | - (void)drawRect:(CGRect)rect
350 | {
351 | const BOOL anyTextToDraw = YES;
352 |
353 | if (anyTextToDraw)
354 | {
355 | CGContextRef ctx = UIGraphicsGetCurrentContext();
356 |
357 | const CGFloat marginToDrawInside = [self marginToDrawInside];
358 | const CGRect rectToDraw = CGRectInset(rect, marginToDrawInside, marginToDrawInside);
359 |
360 | UIBezierPath *borderPath = [UIBezierPath bezierPathWithRoundedRect:rectToDraw byRoundingCorners:(UIRectCorner)UIRectCornerAllCorners cornerRadii:CGSizeMake(self.badgeViewCornerRadius, self.badgeViewCornerRadius)];
361 |
362 | /* 绘制背景色,背景阴影 */
363 | CGContextSaveGState(ctx);
364 | {
365 | CGContextAddPath(ctx, borderPath.CGPath);
366 |
367 | CGContextSetFillColorWithColor(ctx, self.badgeBackgroundColor.CGColor);
368 | CGContextSetShadowWithColor(ctx, self.badgeShadowSize, XMBadgeViewShadowRadius, self.badgeShadowColor.CGColor);
369 |
370 | CGContextDrawPath(ctx, kCGPathFill);
371 | }
372 | CGContextRestoreGState(ctx);
373 |
374 | /* 绘制边框 */
375 | CGContextSaveGState(ctx);
376 | {
377 | CGContextAddPath(ctx, borderPath.CGPath);
378 |
379 | CGContextSetLineWidth(ctx, self.badgeStrokeWidth);
380 | CGContextSetStrokeColorWithColor(ctx, self.badgeStrokeColor.CGColor);
381 |
382 | CGContextDrawPath(ctx, kCGPathStroke);
383 | }
384 | CGContextRestoreGState(ctx);
385 |
386 | /* 绘制文字 */
387 |
388 | CGContextSaveGState(ctx);
389 | {
390 | CGContextSetFillColorWithColor(ctx, self.badgeTextColor.CGColor);
391 | CGContextSetShadowWithColor(ctx, self.badgeTextShadowSize, 1.0, self.badgeTextShadowColor.CGColor);
392 |
393 | CGRect textFrame = rectToDraw;
394 | const CGSize textSize = [self sizeOfTextForCurrentSettings];
395 |
396 | textFrame.size.height = textSize.height;
397 | textFrame.origin.y = rectToDraw.origin.y + ceilf((rectToDraw.size.height - textFrame.size.height) / 2.0f);
398 |
399 | NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
400 | paragraphStyle.alignment = NSTextAlignmentCenter;
401 | [self.badgeText drawInRect:textFrame withAttributes:@{NSFontAttributeName:self.badgeTextFont,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:self.badgeTextColor}];
402 | }
403 | CGContextRestoreGState(ctx);
404 | }
405 | }
406 |
407 |
408 | #pragma mark - Response Actions
409 |
410 | /**
411 | * 处理拖动手势
412 | *
413 | * @param pan
414 | */
415 | - (void)handlePan:(UIPanGestureRecognizer *)pan{
416 | CGPoint panPoint = [pan translationInView:self];
417 |
418 | CGPoint changeCenter = self.center;
419 | changeCenter.x += panPoint.x;
420 | changeCenter.y += panPoint.y;
421 | self.center = changeCenter;
422 | [pan setTranslation:CGPointZero inView:self];
423 |
424 | //俩个圆的中心点之间的距离
425 | CGFloat dist = [self pointToPoitnDistanceWithPoint:self.center potintB:self.smallBadgeView.center];
426 |
427 | if (dist < self.maxDistance) {
428 |
429 | CGFloat cornerRadius = self.badgeViewCornerRadius;
430 | CGFloat samllCrecleRadius = cornerRadius - dist / 20;
431 | self.smallBadgeView.bounds = CGRectMake(0, 0, samllCrecleRadius * (2 - 0.5), samllCrecleRadius * (2 - 0.5));
432 | self.smallBadgeView.layer.cornerRadius = self.smallBadgeView.bounds.size.width / 2;
433 |
434 | if (self.smallBadgeView.hidden == NO && dist > 0) {
435 | //画不规则矩形
436 | self.shapeLayer.path = [self pathWithBigCirCleView:self smallCirCleView:_smallBadgeView].CGPath;
437 | }
438 | } else {
439 |
440 | [self.shapeLayer removeFromSuperlayer];
441 | self.shapeLayer = nil;
442 | self.smallBadgeView.hidden = YES;
443 |
444 | }
445 |
446 | if (pan.state == UIGestureRecognizerStateEnded) {
447 |
448 | if (dist > self.maxDistance) {
449 | [self reset];
450 | [UIView animateWithDuration:.3 animations:^{
451 | self.alpha = 0.0f;
452 | }completion:^(BOOL finished) {
453 | [self removeFromSuperview];
454 | }];
455 | } else {
456 |
457 | [self.shapeLayer removeFromSuperlayer];
458 | self.shapeLayer = nil;
459 |
460 | [UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.2 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
461 | self.center = self.smallBadgeView.center;
462 | } completion:^(BOOL finished) {
463 | self.smallBadgeView.hidden = NO;
464 | }];
465 | }
466 | }
467 | }
468 |
469 |
470 | - (void)handleTap:(UITapGestureRecognizer *)tap{
471 | [self reset];
472 | self.hidden = YES;
473 | [self removeFromSuperview];
474 | }
475 |
476 | #pragma mark - Private
477 |
478 | - (void)setUp{
479 |
480 | self.maxDistance = 100;
481 |
482 | UIPanGestureRecognizer *panGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
483 | [self addGestureRecognizer:panGes];
484 |
485 | UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
486 | [self addGestureRecognizer:tapGes];
487 |
488 | }
489 |
490 | /**
491 | * 重置,将smallBadgeView,shapeLayer 从父view中移除,以免内存泄露
492 | */
493 | - (void)reset{
494 | [self.smallBadgeView removeFromSuperview];
495 | self.smallBadgeView = nil;
496 |
497 | [self.shapeLayer removeFromSuperlayer];
498 | self.shapeLayer = nil;
499 | }
500 |
501 | /**
502 | * 计算两点之间距离
503 | *
504 | * @param pointA A点
505 | * @param pointB B点
506 | *
507 | * @code
508 | * CGFloat distance = [self pointToPoitnDistanceWithPoint:aPoint potintB:bPoint]
509 | * @endcode
510 | *
511 | * @return 两点之间距离
512 | */
513 | - (CGFloat)pointToPoitnDistanceWithPoint:(CGPoint)pointA potintB:(CGPoint)pointB
514 | {
515 | CGFloat offestX = pointA.x - pointB.x;
516 | CGFloat offestY = pointA.y - pointB.y;
517 | CGFloat dist = sqrtf(offestX * offestX + offestY * offestY);
518 |
519 | return dist;
520 | }
521 |
522 |
523 | /**
524 | * 绘制贝塞尔曲线路径
525 | *
526 | * @param bigCirCleView 被拖动的View
527 | * @param smallCirCleView 留在原地的view
528 | *
529 | * @return UIBezierPath 的实例
530 | */
531 | - (UIBezierPath *)pathWithBigCirCleView:(UIView *)bigCirCleView smallCirCleView:(UIView *)smallCirCleView
532 | {
533 | CGPoint bigCenter = bigCirCleView.center;
534 | CGFloat x2 = bigCenter.x;
535 | CGFloat y2 = bigCenter.y;
536 | CGFloat r2 = bigCirCleView.bounds.size.width / 2;
537 |
538 | CGPoint smallCenter = smallCirCleView.center;
539 | CGFloat x1 = smallCenter.x;
540 | CGFloat y1 = smallCenter.y;
541 | CGFloat r1 = smallCirCleView.bounds.size.width / 2;
542 |
543 | // 获取圆心距离
544 | CGFloat d = [self pointToPoitnDistanceWithPoint:self.smallBadgeView.center potintB:self.center];
545 | CGFloat sinθ = 0.0f;
546 | CGFloat cosθ = 0.0f;
547 | if (d == 0) {
548 | sinθ = 0;
549 | cosθ = 1;
550 | }else{
551 | sinθ = (x2 - x1) / d;
552 | cosθ = (y2 - y1) / d;
553 | }
554 |
555 | // 坐标系基于父控件
556 | CGPoint pointA = CGPointMake(x1 - r1 * cosθ , y1 + r1 * sinθ);
557 | CGPoint pointB = CGPointMake(x1 + r1 * cosθ , y1 - r1 * sinθ);
558 | CGPoint pointC = CGPointMake(x2 + r2 * cosθ , y2 - r2 * sinθ);
559 | CGPoint pointD = CGPointMake(x2 - r2 * cosθ , y2 + r2 * sinθ);
560 | CGPoint pointO = CGPointMake(pointA.x + d / 2 * sinθ , pointA.y + d / 2 * cosθ);
561 | CGPoint pointP = CGPointMake(pointB.x + d / 2 * sinθ , pointB.y + d / 2 * cosθ);
562 |
563 | UIBezierPath *path = [UIBezierPath bezierPath];
564 | // A
565 | [path moveToPoint:pointA];
566 | // AB
567 | [path addLineToPoint:pointB];
568 | // 绘制BC曲线
569 | [path addQuadCurveToPoint:pointC controlPoint:pointP];
570 | // CD
571 | [path addLineToPoint:pointD];
572 | // 绘制DA曲线
573 | [path addQuadCurveToPoint:pointA controlPoint:pointO];
574 |
575 | return path;
576 | }
577 |
578 |
579 | - (CGSize)sizeOfTextForCurrentSettings
580 | {
581 |
582 | return [self.badgeText sizeWithAttributes:@{NSFontAttributeName:self.badgeTextFont}];
583 | // XMBadgeViewSilenceDeprecatedMethodStart();
584 | // return [self.badgeText sizeWithFont:self.badgeTextFont];
585 | // XMBadgeViewSilenceDeprecatedMethodEnd();
586 | }
587 |
588 | #pragma mark - Setters
589 |
590 | - (void)setBadgeViewAlignment:(XMBadgeViewAlignment)badgeViewAlignment{
591 |
592 | if (badgeViewAlignment != _badgeViewAlignment) {
593 | _badgeViewAlignment = badgeViewAlignment;
594 | [self setNeedsLayout];
595 | }
596 |
597 | }
598 |
599 | - (void)setBadgePositionAdjustment:(CGPoint)badgePositionAdjustment
600 | {
601 | _badgePositionAdjustment = badgePositionAdjustment;
602 |
603 | [self setNeedsLayout];
604 | }
605 |
606 | - (void)setBadgeText:(NSString *)badgeText
607 | {
608 | if (badgeText != _badgeText)
609 | {
610 | _badgeText = [badgeText copy];
611 |
612 | [self setNeedsLayout];
613 | }
614 | }
615 |
616 | - (void)setBadgeTextColor:(UIColor *)badgeTextColor
617 | {
618 | if (badgeTextColor != _badgeTextColor)
619 | {
620 | _badgeTextColor = badgeTextColor;
621 |
622 | [self setNeedsDisplay];
623 | }
624 | }
625 |
626 | - (void)setBadgeTextShadowColor:(UIColor *)badgeTextShadowColor
627 | {
628 | if (badgeTextShadowColor != _badgeTextShadowColor)
629 | {
630 | _badgeTextShadowColor = badgeTextShadowColor;
631 |
632 | [self setNeedsDisplay];
633 | }
634 | }
635 |
636 | - (void)setBadgeTextShadowSize:(CGSize)badgeTextShadowSize{
637 |
638 | _badgeTextShadowSize = badgeTextShadowSize;
639 | [self setNeedsDisplay];
640 |
641 | }
642 |
643 |
644 | - (void)setBadgeTextFont:(UIFont *)badgeTextFont
645 | {
646 | if (badgeTextFont != _badgeTextFont)
647 | {
648 | _badgeTextFont = badgeTextFont;
649 |
650 | [self setNeedsLayout];
651 | [self setNeedsDisplay];
652 | }
653 | }
654 |
655 | - (void)setBadgeBackgroundColor:(UIColor *)badgeBackgroundColor
656 | {
657 | if (badgeBackgroundColor != _badgeBackgroundColor)
658 | {
659 | _badgeBackgroundColor = badgeBackgroundColor;
660 |
661 | [self setNeedsDisplay];
662 | }
663 | }
664 |
665 | - (void)setBadgeStrokeWidth:(CGFloat)badgeStrokeWidth
666 | {
667 | if (badgeStrokeWidth != _badgeStrokeWidth)
668 | {
669 | _badgeStrokeWidth = badgeStrokeWidth;
670 |
671 | [self setNeedsLayout];
672 | [self setNeedsDisplay];
673 | }
674 | }
675 |
676 | - (void)setBadgeStrokeColor:(UIColor *)badgeStrokeColor
677 | {
678 | if (badgeStrokeColor != _badgeStrokeColor)
679 | {
680 | _badgeStrokeColor = badgeStrokeColor;
681 |
682 | [self setNeedsDisplay];
683 | }
684 | }
685 |
686 | - (void)setBadgeShadowColor:(UIColor *)badgeShadowColor
687 | {
688 | if (badgeShadowColor != _badgeShadowColor)
689 | {
690 | _badgeShadowColor = badgeShadowColor;
691 |
692 | [self setNeedsDisplay];
693 | }
694 | }
695 |
696 | - (void)setBadgeShadowSize:(CGSize)badgeShadowSize
697 | {
698 | if (!CGSizeEqualToSize(badgeShadowSize, _badgeShadowSize))
699 | {
700 | _badgeShadowSize = badgeShadowSize;
701 |
702 | [self setNeedsDisplay];
703 | }
704 | }
705 |
706 |
707 | - (void)setPanable:(BOOL)panable{
708 | _panable = panable;
709 | self.userInteractionEnabled = _panable;
710 | }
711 |
712 | #pragma mark - Getters
713 |
714 | - (CGFloat)badgeViewCornerRadius{
715 | if (_badgeViewCornerRadius <= 0.0f) {
716 | return self.bounds.size.width/2;
717 | }
718 | return _badgeViewCornerRadius;
719 | }
720 |
721 | - (UIView *)smallBadgeView{
722 | if (!_smallBadgeView) {
723 | _smallBadgeView = [[UIView alloc] init];
724 | _smallBadgeView.backgroundColor = self.badgeBackgroundColor;
725 | [self.superview insertSubview:_smallBadgeView belowSubview:self];
726 | }
727 | return _smallBadgeView;
728 | }
729 |
730 | - (CAShapeLayer *)shapeLayer{
731 | if (!_shapeLayer) {
732 | _shapeLayer = [CAShapeLayer layer];
733 | _shapeLayer.fillColor = self.badgeBackgroundColor.CGColor;
734 | [self.superview.layer insertSublayer:_shapeLayer below:self.layer];
735 | }
736 | return _shapeLayer;
737 | }
738 |
739 | @end
740 |
--------------------------------------------------------------------------------