├── .DS_Store ├── .gitignore ├── LICENSE ├── LxTabBadgePoint.podspec ├── LxTabBadgePoint ├── .DS_Store ├── UIViewController+LxTabBadgePoint.h └── UIViewController+LxTabBadgePoint.m ├── LxTabBadgePointDemo ├── .DS_Store ├── LxTabBadgePointDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── LxTabBadgePointDemo │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperLx/LxTabBadgePoint/36004b1c9c481f4efd555ba06013f8e707be3306/.DS_Store -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Developer.Lx 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LxTabBadgePoint.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "LxTabBadgePoint" 3 | s.version = "1.0.0" 4 | s.summary = "Easily custom viewController's tabBar badge view!" 5 | 6 | s.homepage = "https://github.com/DeveloperLx/LxTabBadgePoint" 7 | s.license = 'MIT' 8 | s.authors = { 'DeveloperLx' => 'developerlx@yeah.com' } 9 | s.platform = :ios, "7.0" 10 | s.ios.deployment_target = "7.0" 11 | s.source = { :git => "https://github.com/DeveloperLx/LxTabBadgePoint.git", :tag => s.version} 12 | s.source_files = 'LxTabBadgePoint/UIViewController+LxTabBadgePoint.*' 13 | s.requires_arc = true 14 | s.frameworks = 'UIKit' 15 | end 16 | -------------------------------------------------------------------------------- /LxTabBadgePoint/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperLx/LxTabBadgePoint/36004b1c9c481f4efd555ba06013f8e707be3306/LxTabBadgePoint/.DS_Store -------------------------------------------------------------------------------- /LxTabBadgePoint/UIViewController+LxTabBadgePoint.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+LxTabBadgePoint.h 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/24. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | /** 10 | * @author DeveloperLx, 15-11-24 12:11:27 11 | * 12 | * @TODO: Cannot set tabBadgePointView to nil indeed, change it if possible. 13 | * 14 | */ 15 | 16 | #import 17 | 18 | @interface UIViewController (LxTabBadgePoint) 19 | 20 | @property (nonatomic,assign) BOOL showTabBadgePoint; 21 | @property (nonatomic,retain) UIView * tabBadgePointView; 22 | @property (nonatomic,assign) UIOffset tabBadgePointViewOffset; 23 | 24 | @property (nonatomic,readonly,getter = isEmbedInTabBarController) BOOL embedInTabBarController; 25 | @property (nonatomic,readonly) NSInteger tabIndex; 26 | @property (nonatomic,readonly) UIView * tabBarButton; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /LxTabBadgePoint/UIViewController+LxTabBadgePoint.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+LxTabBadgePoint.m 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/24. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+LxTabBadgePoint.h" 10 | #import 11 | 12 | @implementation UIViewController (LxTabBadgePoint) 13 | 14 | #pragma mark - public method 15 | 16 | - (void)setShowTabBadgePoint:(BOOL)showTabBadgePoint 17 | { 18 | if (showTabBadgePoint && self.tabBadgePointView.superview == nil) { 19 | self.tabBadgePointView.center = self.tabBadgePointViewCenter; 20 | [self.tabBarButton addSubview:self.tabBadgePointView]; 21 | } 22 | 23 | self.tabBadgePointView.hidden = showTabBadgePoint == NO; 24 | } 25 | 26 | - (BOOL)showTabBadgePoint 27 | { 28 | return !self.tabBadgePointView.hidden; 29 | } 30 | 31 | - (void)setTabBadgePointView:(UIView *)tabBadgePointView 32 | { 33 | if (tabBadgePointView.superview) { 34 | [tabBadgePointView removeFromSuperview]; 35 | } 36 | 37 | tabBadgePointView.hidden = YES; 38 | 39 | objc_setAssociatedObject(self, @selector(tabBadgePointView), tabBadgePointView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 40 | } 41 | 42 | - (UIView *)tabBadgePointView 43 | { 44 | UIView * tabBadgePointView = objc_getAssociatedObject(self, @selector(tabBadgePointView)); 45 | 46 | if (tabBadgePointView == nil) { 47 | tabBadgePointView = self.defaultTabBadgePointView; 48 | objc_setAssociatedObject(self, @selector(tabBadgePointView), tabBadgePointView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 49 | } 50 | 51 | return tabBadgePointView; 52 | } 53 | 54 | - (void)setTabBadgePointViewOffset:(UIOffset)tabBadgePointViewOffset 55 | { 56 | objc_setAssociatedObject(self, @selector(tabBadgePointViewOffset), [NSValue valueWithUIOffset:tabBadgePointViewOffset], OBJC_ASSOCIATION_RETAIN_NONATOMIC); 57 | 58 | self.tabBadgePointView.center = self.tabBadgePointViewCenter; 59 | } 60 | 61 | - (UIOffset)tabBadgePointViewOffset 62 | { 63 | id tabBadgePointViewOffsetObject = objc_getAssociatedObject(self, @selector(tabBadgePointViewOffset)); 64 | UIOffset tabBadgePointViewOffset = [tabBadgePointViewOffsetObject UIOffsetValue]; 65 | return tabBadgePointViewOffset; 66 | } 67 | 68 | - (BOOL)isEmbedInTabBarController 69 | { 70 | if (self.tabBarController == nil) { 71 | return NO; 72 | } 73 | 74 | BOOL isEmbedInTabBarController = NO; 75 | 76 | for (NSInteger i = 0; i < self.tabBarController.viewControllers.count; i++) { 77 | 78 | UIViewController * vc = self.tabBarController.viewControllers[i]; 79 | 80 | if (vc == self) { 81 | isEmbedInTabBarController = YES; 82 | self.tabIndex = i; 83 | break; 84 | } 85 | } 86 | 87 | return isEmbedInTabBarController; 88 | } 89 | 90 | - (void)setTabIndex:(NSInteger)tabIndex 91 | { 92 | objc_setAssociatedObject(self, @selector(tabIndex), @(tabIndex), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 93 | } 94 | 95 | - (NSInteger)tabIndex 96 | { 97 | if (self.embedInTabBarController == NO) { 98 | NSLog(@"LxTabBadgePoint:This viewController not embed in tabBarController"); 99 | return NSNotFound; 100 | } 101 | 102 | id tabIndexObject = objc_getAssociatedObject(self, @selector(tabIndex)); 103 | NSInteger tabIndex = [tabIndexObject integerValue]; 104 | return tabIndex; 105 | } 106 | 107 | - (UIView *)tabBarButton 108 | { 109 | if (self.embedInTabBarController == NO) { 110 | NSLog(@"LxTabBadgePoint:This viewController not embed in tabBarController"); 111 | return nil; 112 | } 113 | 114 | static NSMutableArray * tabBarButtonArray = nil; 115 | 116 | if (tabBarButtonArray == nil) { 117 | 118 | tabBarButtonArray = [[NSMutableArray alloc]init]; 119 | 120 | for (id subView in self.tabBarController.tabBar.subviews) { 121 | 122 | if ([NSStringFromClass([subView class]) hasPrefix:@"UITabBarButton"]) { 123 | 124 | [tabBarButtonArray addObject:subView]; 125 | } 126 | } 127 | 128 | [tabBarButtonArray sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { 129 | 130 | UIView * tabBarButton1 = (UIView *)obj1; 131 | UIView * tabBarButton2 = (UIView *)obj2; 132 | 133 | return CGRectGetMinX(tabBarButton1.frame) > CGRectGetMinX(tabBarButton2.frame); 134 | }]; 135 | } 136 | 137 | NSInteger tabIndex = self.tabIndex; 138 | 139 | if (tabIndex >= 0 && tabIndex < tabBarButtonArray.count) { 140 | 141 | return tabBarButtonArray[tabIndex]; 142 | } 143 | else { 144 | NSLog(@"LxTabBadgePoint:Not found corresponding tabBarButton !!!"); 145 | return nil; 146 | } 147 | } 148 | 149 | #pragma mark - private method (Can custom.) 150 | 151 | - (CGPoint)tabBadgePointViewCenter 152 | { 153 | UIView * tabBarButton = self.tabBarButton; 154 | 155 | CGPoint tabBadgePointViewCenter = CGPointMake(CGRectGetMidX(tabBarButton.bounds) + 14, 8.5); 156 | tabBadgePointViewCenter.x += self.tabBadgePointViewOffset.horizontal; 157 | tabBadgePointViewCenter.y += self.tabBadgePointViewOffset.vertical; 158 | return tabBadgePointViewCenter; 159 | } 160 | 161 | - (UIView *)defaultTabBadgePointView 162 | { 163 | CGFloat const defaultTabBadgePointViewRadius = 4.5; 164 | 165 | CGRect defaultTabBadgePointViewFrame = (CGRect){CGPointZero, CGSizeMake(defaultTabBadgePointViewRadius * 2, defaultTabBadgePointViewRadius * 2)}; 166 | UIView * defaultTabBadgePointView = [[UIView alloc]initWithFrame:defaultTabBadgePointViewFrame]; 167 | defaultTabBadgePointView.backgroundColor = [UIColor redColor]; 168 | defaultTabBadgePointView.layer.cornerRadius = defaultTabBadgePointViewRadius; 169 | defaultTabBadgePointView.layer.masksToBounds = YES; 170 | 171 | defaultTabBadgePointView.hidden = YES; 172 | 173 | return defaultTabBadgePointView; 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperLx/LxTabBadgePoint/36004b1c9c481f4efd555ba06013f8e707be3306/LxTabBadgePointDemo/.DS_Store -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B634BCF71C032656004B05D8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B634BCF61C032656004B05D8 /* main.m */; }; 11 | B634BCFA1C032656004B05D8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B634BCF91C032656004B05D8 /* AppDelegate.m */; }; 12 | B634BCFD1C032656004B05D8 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B634BCFC1C032656004B05D8 /* ViewController.m */; }; 13 | B634BD001C032656004B05D8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B634BCFE1C032656004B05D8 /* Main.storyboard */; }; 14 | B634BD021C032656004B05D8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B634BD011C032656004B05D8 /* Assets.xcassets */; }; 15 | B634BD051C032656004B05D8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B634BD031C032656004B05D8 /* LaunchScreen.storyboard */; }; 16 | B6350E531C0606450052E507 /* UIViewController+LxTabBadgePoint.m in Sources */ = {isa = PBXBuildFile; fileRef = B6350E521C0606450052E507 /* UIViewController+LxTabBadgePoint.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | B634BCF21C032656004B05D8 /* LxTabBadgePointDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LxTabBadgePointDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | B634BCF61C032656004B05D8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | B634BCF81C032656004B05D8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | B634BCF91C032656004B05D8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | B634BCFB1C032656004B05D8 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 25 | B634BCFC1C032656004B05D8 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 26 | B634BCFF1C032656004B05D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | B634BD011C032656004B05D8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | B634BD041C032656004B05D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | B634BD061C032656004B05D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | B6350E511C0606450052E507 /* UIViewController+LxTabBadgePoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+LxTabBadgePoint.h"; path = "../../LxTabBadgePoint/UIViewController+LxTabBadgePoint.h"; sourceTree = ""; }; 31 | B6350E521C0606450052E507 /* UIViewController+LxTabBadgePoint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+LxTabBadgePoint.m"; path = "../../LxTabBadgePoint/UIViewController+LxTabBadgePoint.m"; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | B634BCEF1C032656004B05D8 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | B634BCE91C032656004B05D8 = { 46 | isa = PBXGroup; 47 | children = ( 48 | B634BCF41C032656004B05D8 /* LxTabBadgePointDemo */, 49 | B634BCF31C032656004B05D8 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | B634BCF31C032656004B05D8 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | B634BCF21C032656004B05D8 /* LxTabBadgePointDemo.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | B634BCF41C032656004B05D8 /* LxTabBadgePointDemo */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | B634BD0F1C0326AC004B05D8 /* LxTabBadgePoint */, 65 | B634BCF81C032656004B05D8 /* AppDelegate.h */, 66 | B634BCF91C032656004B05D8 /* AppDelegate.m */, 67 | B634BCFB1C032656004B05D8 /* ViewController.h */, 68 | B634BCFC1C032656004B05D8 /* ViewController.m */, 69 | B634BCF51C032656004B05D8 /* Supporting Files */, 70 | ); 71 | path = LxTabBadgePointDemo; 72 | sourceTree = ""; 73 | }; 74 | B634BCF51C032656004B05D8 /* Supporting Files */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | B634BD011C032656004B05D8 /* Assets.xcassets */, 78 | B634BD061C032656004B05D8 /* Info.plist */, 79 | B634BD031C032656004B05D8 /* LaunchScreen.storyboard */, 80 | B634BCF61C032656004B05D8 /* main.m */, 81 | B634BCFE1C032656004B05D8 /* Main.storyboard */, 82 | ); 83 | name = "Supporting Files"; 84 | sourceTree = ""; 85 | }; 86 | B634BD0F1C0326AC004B05D8 /* LxTabBadgePoint */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | B6350E511C0606450052E507 /* UIViewController+LxTabBadgePoint.h */, 90 | B6350E521C0606450052E507 /* UIViewController+LxTabBadgePoint.m */, 91 | ); 92 | name = LxTabBadgePoint; 93 | sourceTree = ""; 94 | }; 95 | /* End PBXGroup section */ 96 | 97 | /* Begin PBXNativeTarget section */ 98 | B634BCF11C032656004B05D8 /* LxTabBadgePointDemo */ = { 99 | isa = PBXNativeTarget; 100 | buildConfigurationList = B634BD091C032656004B05D8 /* Build configuration list for PBXNativeTarget "LxTabBadgePointDemo" */; 101 | buildPhases = ( 102 | B634BCEE1C032656004B05D8 /* Sources */, 103 | B634BCEF1C032656004B05D8 /* Frameworks */, 104 | B634BCF01C032656004B05D8 /* Resources */, 105 | ); 106 | buildRules = ( 107 | ); 108 | dependencies = ( 109 | ); 110 | name = LxTabBadgePointDemo; 111 | productName = LxTabBadgePointDemo; 112 | productReference = B634BCF21C032656004B05D8 /* LxTabBadgePointDemo.app */; 113 | productType = "com.apple.product-type.application"; 114 | }; 115 | /* End PBXNativeTarget section */ 116 | 117 | /* Begin PBXProject section */ 118 | B634BCEA1C032656004B05D8 /* Project object */ = { 119 | isa = PBXProject; 120 | attributes = { 121 | LastUpgradeCheck = 0710; 122 | ORGANIZATIONNAME = DeveloperLx; 123 | TargetAttributes = { 124 | B634BCF11C032656004B05D8 = { 125 | CreatedOnToolsVersion = 7.1.1; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = B634BCED1C032656004B05D8 /* Build configuration list for PBXProject "LxTabBadgePointDemo" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = English; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = B634BCE91C032656004B05D8; 138 | productRefGroup = B634BCF31C032656004B05D8 /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | B634BCF11C032656004B05D8 /* LxTabBadgePointDemo */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | B634BCF01C032656004B05D8 /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | B634BD051C032656004B05D8 /* LaunchScreen.storyboard in Resources */, 153 | B634BD021C032656004B05D8 /* Assets.xcassets in Resources */, 154 | B634BD001C032656004B05D8 /* Main.storyboard in Resources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXResourcesBuildPhase section */ 159 | 160 | /* Begin PBXSourcesBuildPhase section */ 161 | B634BCEE1C032656004B05D8 /* Sources */ = { 162 | isa = PBXSourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | B634BCFD1C032656004B05D8 /* ViewController.m in Sources */, 166 | B6350E531C0606450052E507 /* UIViewController+LxTabBadgePoint.m in Sources */, 167 | B634BCFA1C032656004B05D8 /* AppDelegate.m in Sources */, 168 | B634BCF71C032656004B05D8 /* main.m in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | B634BCFE1C032656004B05D8 /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | B634BCFF1C032656004B05D8 /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | B634BD031C032656004B05D8 /* LaunchScreen.storyboard */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | B634BD041C032656004B05D8 /* Base */, 187 | ); 188 | name = LaunchScreen.storyboard; 189 | sourceTree = ""; 190 | }; 191 | /* End PBXVariantGroup section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | B634BD071C032656004B05D8 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_CONSTANT_CONVERSION = YES; 204 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_UNREACHABLE_CODE = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | DEBUG_INFORMATION_FORMAT = dwarf; 214 | ENABLE_STRICT_OBJC_MSGSEND = YES; 215 | ENABLE_TESTABILITY = YES; 216 | GCC_C_LANGUAGE_STANDARD = gnu99; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_NO_COMMON_BLOCKS = YES; 219 | GCC_OPTIMIZATION_LEVEL = 0; 220 | GCC_PREPROCESSOR_DEFINITIONS = ( 221 | "DEBUG=1", 222 | "$(inherited)", 223 | ); 224 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 225 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 226 | GCC_WARN_UNDECLARED_SELECTOR = YES; 227 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 228 | GCC_WARN_UNUSED_FUNCTION = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 231 | MTL_ENABLE_DEBUG_INFO = YES; 232 | ONLY_ACTIVE_ARCH = YES; 233 | SDKROOT = iphoneos; 234 | TARGETED_DEVICE_FAMILY = "1,2"; 235 | }; 236 | name = Debug; 237 | }; 238 | B634BD081C032656004B05D8 /* Release */ = { 239 | isa = XCBuildConfiguration; 240 | buildSettings = { 241 | ALWAYS_SEARCH_USER_PATHS = NO; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 256 | COPY_PHASE_STRIP = NO; 257 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 258 | ENABLE_NS_ASSERTIONS = NO; 259 | ENABLE_STRICT_OBJC_MSGSEND = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu99; 261 | GCC_NO_COMMON_BLOCKS = YES; 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 269 | MTL_ENABLE_DEBUG_INFO = NO; 270 | SDKROOT = iphoneos; 271 | TARGETED_DEVICE_FAMILY = "1,2"; 272 | VALIDATE_PRODUCT = YES; 273 | }; 274 | name = Release; 275 | }; 276 | B634BD0A1C032656004B05D8 /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | INFOPLIST_FILE = LxTabBadgePointDemo/Info.plist; 281 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 282 | PRODUCT_BUNDLE_IDENTIFIER = com.etiantian.LxTabBadgePointDemo; 283 | PRODUCT_NAME = "$(TARGET_NAME)"; 284 | }; 285 | name = Debug; 286 | }; 287 | B634BD0B1C032656004B05D8 /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | INFOPLIST_FILE = LxTabBadgePointDemo/Info.plist; 292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 293 | PRODUCT_BUNDLE_IDENTIFIER = com.etiantian.LxTabBadgePointDemo; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | }; 296 | name = Release; 297 | }; 298 | /* End XCBuildConfiguration section */ 299 | 300 | /* Begin XCConfigurationList section */ 301 | B634BCED1C032656004B05D8 /* Build configuration list for PBXProject "LxTabBadgePointDemo" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | B634BD071C032656004B05D8 /* Debug */, 305 | B634BD081C032656004B05D8 /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | B634BD091C032656004B05D8 /* Build configuration list for PBXNativeTarget "LxTabBadgePointDemo" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | B634BD0A1C032656004B05D8 /* Debug */, 314 | B634BD0B1C032656004B05D8 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | defaultConfigurationName = Release; 318 | }; 319 | /* End XCConfigurationList section */ 320 | }; 321 | rootObject = B634BCEA1C032656004B05D8 /* Project object */; 322 | } 323 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperLx/LxTabBadgePoint/36004b1c9c481f4efd555ba06013f8e707be3306/LxTabBadgePointDemo/LxTabBadgePointDemo/.DS_Store -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/23. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/23. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | #import "UIViewController+LxTabBadgePoint.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | 21 | ViewController * vc1 = [[ViewController alloc]init]; 22 | vc1.title = @"vc1"; 23 | 24 | ViewController * vc2 = [[ViewController alloc]init]; 25 | vc2.title = @"vc2"; 26 | 27 | ViewController * vc3 = [[ViewController alloc]init]; 28 | vc3.title = @"vc3"; 29 | 30 | ViewController * vc4 = [[ViewController alloc]init]; 31 | vc4.title = @"vc4"; 32 | 33 | UINavigationController * nc1 = [[UINavigationController alloc]initWithRootViewController:vc1]; 34 | UINavigationController * nc2 = [[UINavigationController alloc]initWithRootViewController:vc2]; 35 | UINavigationController * nc3 = [[UINavigationController alloc]initWithRootViewController:vc3]; 36 | UINavigationController * nc4 = [[UINavigationController alloc]initWithRootViewController:vc4]; 37 | 38 | nc2.tabBadgePointView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"audio_pause"]]; 39 | nc3.tabBadgePointView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"exclamation"]]; 40 | nc4.tabBadgePointView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fans_each_other"]]; 41 | 42 | UITabBarController * tbc = [[UITabBarController alloc]init]; 43 | tbc.viewControllers = @[nc1, nc2, nc3, nc4]; 44 | 45 | self.window.rootViewController = tbc; 46 | [self.window makeKeyAndVisible]; 47 | 48 | return YES; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperLx/LxTabBadgePoint/36004b1c9c481f4efd555ba06013f8e707be3306/LxTabBadgePointDemo/LxTabBadgePointDemo/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/Assets.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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/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 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/23. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/23. 6 | // Copyright © 2015年 DeveloperLx. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIViewController+LxTabBadgePoint.h" 11 | 12 | 13 | @implementation ViewController 14 | 15 | - (void)viewDidLoad 16 | { 17 | [super viewDidLoad]; 18 | 19 | self.view.backgroundColor = [UIColor colorWithHue:arc4random()%100/100.0 saturation:arc4random()%100/100.0 brightness:arc4random()%100/100.0 alpha:1]; 20 | 21 | UIButton * handleTabPointButton = [UIButton buttonWithType:UIButtonTypeCustom]; 22 | handleTabPointButton.showsTouchWhenHighlighted = YES; 23 | handleTabPointButton.titleLabel.font = [UIFont systemFontOfSize:20]; 24 | handleTabPointButton.backgroundColor = [UIColor whiteColor]; 25 | [handleTabPointButton setTitle:@"show badge view" forState:UIControlStateNormal]; 26 | [handleTabPointButton setTitle:@"hide badge view" forState:UIControlStateSelected]; 27 | [handleTabPointButton setTitleColor:self.view.backgroundColor forState:UIControlStateNormal]; 28 | [handleTabPointButton addTarget:self action:@selector(handleTabPointButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; 29 | [self.view addSubview:handleTabPointButton]; 30 | 31 | handleTabPointButton.translatesAutoresizingMaskIntoConstraints = NO; 32 | 33 | NSLayoutConstraint * handleTabPointButtonCenterXConstraint = 34 | [NSLayoutConstraint constraintWithItem:handleTabPointButton 35 | attribute:NSLayoutAttributeCenterX 36 | relatedBy:NSLayoutRelationEqual 37 | toItem:self.view 38 | attribute:NSLayoutAttributeCenterX 39 | multiplier:1 40 | constant:0]; 41 | 42 | NSLayoutConstraint * handleTabPointButtonCenterYConstraint = 43 | [NSLayoutConstraint constraintWithItem:handleTabPointButton 44 | attribute:NSLayoutAttributeCenterY 45 | relatedBy:NSLayoutRelationEqual 46 | toItem:self.view 47 | attribute:NSLayoutAttributeCenterY 48 | multiplier:1 49 | constant:0]; 50 | 51 | NSLayoutConstraint * handleTabPointButtonWidthConstraint = 52 | [NSLayoutConstraint constraintWithItem:handleTabPointButton 53 | attribute:NSLayoutAttributeWidth 54 | relatedBy:NSLayoutRelationEqual 55 | toItem:nil 56 | attribute:NSLayoutAttributeWidth 57 | multiplier:1 58 | constant:180]; 59 | 60 | NSLayoutConstraint * handleTabPointButtonHeightConstraint = 61 | [NSLayoutConstraint constraintWithItem:handleTabPointButton 62 | attribute:NSLayoutAttributeHeight 63 | relatedBy:NSLayoutRelationEqual 64 | toItem:nil 65 | attribute:NSLayoutAttributeHeight 66 | multiplier:1 67 | constant:60]; 68 | 69 | [self.view addConstraints:@[handleTabPointButtonCenterXConstraint, 70 | handleTabPointButtonCenterYConstraint, 71 | handleTabPointButtonWidthConstraint, 72 | handleTabPointButtonHeightConstraint]]; 73 | } 74 | 75 | - (void)handleTabPointButtonClicked:(UIButton *)btn 76 | { 77 | btn.selected = self.navigationController.showTabBadgePoint = !self.navigationController.showTabBadgePoint; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /LxTabBadgePointDemo/LxTabBadgePointDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LxTabBadgePointDemo 4 | // 5 | // Created by DeveloperLx on 15/11/23. 6 | // Copyright © 2015年 DeveloperLx. 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LxTabBadgePoint 2 | Easily custom viewController's tabBar badge view. 3 | 4 | ### Installation 5 | You only need drag UIViewController+LxTabBadgePoint.h and UIViewController+LxTabBadgePoint.m to your project. 6 | 7 | ### CocoaPods 8 | pod 'LxTabBadgePoint', '~> 1.0.0' 9 | 10 | ### Support 11 | Minimum support iOS version: iOS 6.0 12 | 13 | ### Usage 14 | ```objc 15 | #import "UIViewController+LxTabBadgePoint.h" 16 | 17 | // Judge whether embed in tabbarController 18 | BOOL isEmbedInTabBarController = viewController.isEmbedInTabBarController; 19 | 20 | // If yes, you can set showTabBadgePoint to show/hide tabBar badge view. 21 | viewController.showTabBadgePoint = YES/NO; 22 | 23 | // Red point is default effect, you can change it to any you want view. 24 | viewController.tabBadgePointView = ...(You customed UIView object); 25 | 26 | // You can adjust the tabBar badge view's position. 27 | viewController.tabBadgePointViewOffset = UIOffsetMake(3, 6); 28 | ``` 29 | 30 | ### License 31 | LxTabBadgePoint is available under the MIT License. See the LICENSE file for more info. --------------------------------------------------------------------------------