├── BadgeControl.podspec ├── BadgeControl.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── robinkrenecky.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcshareddata │ └── xcschemes │ │ └── BadgeControl.xcscheme └── xcuserdata │ └── robinkrenecky.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── BadgeControl ├── BadgeAnimations.swift ├── BadgeCenterPosition.swift ├── BadgeControl.h ├── BadgeController.swift ├── BadgeView.swift └── Info.plist ├── BadgeControlExample ├── BadgeControlExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── robinkrenecky.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── robinkrenecky.xcuserdatad │ │ └── xcschemes │ │ ├── BadgeControlExample.xcscheme │ │ └── xcschememanagement.plist ├── BadgeControlExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── Image.imageset │ │ │ ├── Contents.json │ │ │ └── iconmonstr-speech-bubble-30-240.png │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── Main.storyboard │ └── ViewController.swift └── Podfile ├── LICENSE ├── README.md └── RepositoryImages ├── all.gif ├── boom.gif ├── default.gif ├── fadeIn.gif ├── leftRight.gif ├── rightLeft.gif ├── roll.gif └── upperLeftCorner.gif /BadgeControl.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "BadgeControl" 3 | s.version = "1.2.1" 4 | s.summary = "Simple framework for adding a badge to UIView." 5 | s.description = "Simply attach BadgeController to any UIView's subclasses and easily control the badge. Customize size, position, background color, text color and animation of the badge." 6 | s.homepage = "https://github.com/kiwisip/BadgeControl.git" 7 | s.license = "MIT" 8 | s.author = { "Robin Krenecky" => "rkrenecky@gmail.com" } 9 | s.platform = :ios, "9.0" 10 | s.source = { :git => "https://github.com/kiwisip/BadgeControl.git", :tag => s.version } 11 | s.source_files = "BadgeControl", "BadgeControl/**/*.{h,m,swift}" 12 | s.exclude_files = "Classes/Exclude" 13 | s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' } 14 | s.ios.deployment_target = "9.0" 15 | s.tvos.deployment_target = "9.0" 16 | s.frameworks = "UIKit" 17 | s.swift_version = "5.0" 18 | end 19 | -------------------------------------------------------------------------------- /BadgeControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7176E45D1F4CCBAE00781455 /* BadgeAnimations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7176E45C1F4CCBAE00781455 /* BadgeAnimations.swift */; }; 11 | 71AE68751F49B2DD00196F80 /* BadgeControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 71AE68731F49B2DD00196F80 /* BadgeControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12 | 71B250231F49B541001E7145 /* BadgeCenterPosition.swift in Headers */ = {isa = PBXBuildFile; fileRef = 71B250201F49B541001E7145 /* BadgeCenterPosition.swift */; }; 13 | 71B250241F49B541001E7145 /* BadgeController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 71B250211F49B541001E7145 /* BadgeController.swift */; }; 14 | 71B250251F49B541001E7145 /* BadgeImageView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 71B250221F49B541001E7145 /* BadgeImageView.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 7176E45C1F4CCBAE00781455 /* BadgeAnimations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeAnimations.swift; sourceTree = ""; }; 19 | 71AE68701F49B2DD00196F80 /* BadgeControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BadgeControl.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 71AE68731F49B2DD00196F80 /* BadgeControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BadgeControl.h; path = BadgeControl/BadgeControl.h; sourceTree = SOURCE_ROOT; }; 21 | 71AE68741F49B2DD00196F80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | 71B250201F49B541001E7145 /* BadgeCenterPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = BadgeCenterPosition.swift; path = BadgeControl/BadgeCenterPosition.swift; sourceTree = SOURCE_ROOT; }; 23 | 71B250211F49B541001E7145 /* BadgeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = BadgeController.swift; path = BadgeControl/BadgeController.swift; sourceTree = SOURCE_ROOT; }; 24 | 71B250221F49B541001E7145 /* BadgeImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = BadgeImageView.swift; path = BadgeControl/BadgeImageView.swift; sourceTree = SOURCE_ROOT; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 71AE686C1F49B2DD00196F80 /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 71AE68661F49B2DD00196F80 = { 39 | isa = PBXGroup; 40 | children = ( 41 | 71AE68721F49B2DD00196F80 /* BadgeControl */, 42 | 71AE68711F49B2DD00196F80 /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 71AE68711F49B2DD00196F80 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 71AE68701F49B2DD00196F80 /* BadgeControl.framework */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 71AE68721F49B2DD00196F80 /* BadgeControl */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 71AE68731F49B2DD00196F80 /* BadgeControl.h */, 58 | 71B250211F49B541001E7145 /* BadgeController.swift */, 59 | 71B250221F49B541001E7145 /* BadgeImageView.swift */, 60 | 71B250201F49B541001E7145 /* BadgeCenterPosition.swift */, 61 | 7176E45C1F4CCBAE00781455 /* BadgeAnimations.swift */, 62 | 71AE68741F49B2DD00196F80 /* Info.plist */, 63 | ); 64 | path = BadgeControl; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXHeadersBuildPhase section */ 70 | 71AE686D1F49B2DD00196F80 /* Headers */ = { 71 | isa = PBXHeadersBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | 71B250251F49B541001E7145 /* BadgeImageView.swift in Headers */, 75 | 71AE68751F49B2DD00196F80 /* BadgeControl.h in Headers */, 76 | 71B250241F49B541001E7145 /* BadgeController.swift in Headers */, 77 | 71B250231F49B541001E7145 /* BadgeCenterPosition.swift in Headers */, 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXHeadersBuildPhase section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 71AE686F1F49B2DD00196F80 /* BadgeControl */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 71AE68781F49B2DD00196F80 /* Build configuration list for PBXNativeTarget "BadgeControl" */; 87 | buildPhases = ( 88 | 71AE686B1F49B2DD00196F80 /* Sources */, 89 | 71AE686C1F49B2DD00196F80 /* Frameworks */, 90 | 71AE686D1F49B2DD00196F80 /* Headers */, 91 | 71AE686E1F49B2DD00196F80 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = BadgeControl; 98 | productName = BadgeControl; 99 | productReference = 71AE68701F49B2DD00196F80 /* BadgeControl.framework */; 100 | productType = "com.apple.product-type.framework"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 71AE68671F49B2DD00196F80 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 0900; 109 | ORGANIZATIONNAME = "Robin Krenecky"; 110 | TargetAttributes = { 111 | 71AE686F1F49B2DD00196F80 = { 112 | CreatedOnToolsVersion = 9.0; 113 | LastSwiftMigration = 0900; 114 | }; 115 | }; 116 | }; 117 | buildConfigurationList = 71AE686A1F49B2DD00196F80 /* Build configuration list for PBXProject "BadgeControl" */; 118 | compatibilityVersion = "Xcode 8.0"; 119 | developmentRegion = en; 120 | hasScannedForEncodings = 0; 121 | knownRegions = ( 122 | en, 123 | ); 124 | mainGroup = 71AE68661F49B2DD00196F80; 125 | productRefGroup = 71AE68711F49B2DD00196F80 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 71AE686F1F49B2DD00196F80 /* BadgeControl */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 71AE686E1F49B2DD00196F80 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | 71AE686B1F49B2DD00196F80 /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 7176E45D1F4CCBAE00781455 /* BadgeAnimations.swift in Sources */, 150 | ); 151 | runOnlyForDeploymentPostprocessing = 0; 152 | }; 153 | /* End PBXSourcesBuildPhase section */ 154 | 155 | /* Begin XCBuildConfiguration section */ 156 | 71AE68761F49B2DD00196F80 /* Debug */ = { 157 | isa = XCBuildConfiguration; 158 | buildSettings = { 159 | ALWAYS_SEARCH_USER_PATHS = NO; 160 | CLANG_ANALYZER_NONNULL = YES; 161 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 162 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 163 | CLANG_CXX_LIBRARY = "libc++"; 164 | CLANG_ENABLE_MODULES = YES; 165 | CLANG_ENABLE_OBJC_ARC = YES; 166 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 167 | CLANG_WARN_BOOL_CONVERSION = YES; 168 | CLANG_WARN_COMMA = YES; 169 | CLANG_WARN_CONSTANT_CONVERSION = YES; 170 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 171 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 172 | CLANG_WARN_EMPTY_BODY = YES; 173 | CLANG_WARN_ENUM_CONVERSION = YES; 174 | CLANG_WARN_INFINITE_RECURSION = YES; 175 | CLANG_WARN_INT_CONVERSION = YES; 176 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 180 | CLANG_WARN_STRICT_PROTOTYPES = YES; 181 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 182 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | CODE_SIGN_IDENTITY = "iPhone Developer"; 186 | COPY_PHASE_STRIP = NO; 187 | CURRENT_PROJECT_VERSION = 1; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu11; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | SWIFT_VERSION = 4.2; 212 | VERSIONING_SYSTEM = "apple-generic"; 213 | VERSION_INFO_PREFIX = ""; 214 | }; 215 | name = Debug; 216 | }; 217 | 71AE68771F49B2DD00196F80 /* Release */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_ANALYZER_NONNULL = YES; 222 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 228 | CLANG_WARN_BOOL_CONVERSION = YES; 229 | CLANG_WARN_COMMA = YES; 230 | CLANG_WARN_CONSTANT_CONVERSION = YES; 231 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 232 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 233 | CLANG_WARN_EMPTY_BODY = YES; 234 | CLANG_WARN_ENUM_CONVERSION = YES; 235 | CLANG_WARN_INFINITE_RECURSION = YES; 236 | CLANG_WARN_INT_CONVERSION = YES; 237 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 241 | CLANG_WARN_STRICT_PROTOTYPES = YES; 242 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 243 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | CODE_SIGN_IDENTITY = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | CURRENT_PROJECT_VERSION = 1; 249 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 250 | ENABLE_NS_ASSERTIONS = NO; 251 | ENABLE_STRICT_OBJC_MSGSEND = YES; 252 | GCC_C_LANGUAGE_STANDARD = gnu11; 253 | GCC_NO_COMMON_BLOCKS = YES; 254 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 255 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 256 | GCC_WARN_UNDECLARED_SELECTOR = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 258 | GCC_WARN_UNUSED_FUNCTION = YES; 259 | GCC_WARN_UNUSED_VARIABLE = YES; 260 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 261 | MTL_ENABLE_DEBUG_INFO = NO; 262 | SDKROOT = iphoneos; 263 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 264 | SWIFT_VERSION = 4.2; 265 | VALIDATE_PRODUCT = YES; 266 | VERSIONING_SYSTEM = "apple-generic"; 267 | VERSION_INFO_PREFIX = ""; 268 | }; 269 | name = Release; 270 | }; 271 | 71AE68791F49B2DD00196F80 /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | CLANG_ENABLE_MODULES = YES; 275 | CODE_SIGN_IDENTITY = ""; 276 | DEFINES_MODULE = YES; 277 | DEVELOPMENT_TEAM = V58W74D958; 278 | DYLIB_COMPATIBILITY_VERSION = 1; 279 | DYLIB_CURRENT_VERSION = 1; 280 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 281 | INFOPLIST_FILE = BadgeControl/Info.plist; 282 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 283 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 284 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 285 | PRODUCT_BUNDLE_IDENTIFIER = cz.kiwisip.BadgeControl; 286 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 287 | SKIP_INSTALL = YES; 288 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 289 | SWIFT_VERSION = 4.2; 290 | TARGETED_DEVICE_FAMILY = "1,2"; 291 | }; 292 | name = Debug; 293 | }; 294 | 71AE687A1F49B2DD00196F80 /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | CLANG_ENABLE_MODULES = YES; 298 | CODE_SIGN_IDENTITY = ""; 299 | DEFINES_MODULE = YES; 300 | DEVELOPMENT_TEAM = V58W74D958; 301 | DYLIB_COMPATIBILITY_VERSION = 1; 302 | DYLIB_CURRENT_VERSION = 1; 303 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 304 | INFOPLIST_FILE = BadgeControl/Info.plist; 305 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 306 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 307 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 308 | PRODUCT_BUNDLE_IDENTIFIER = cz.kiwisip.BadgeControl; 309 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 310 | SKIP_INSTALL = YES; 311 | SWIFT_VERSION = 4.2; 312 | TARGETED_DEVICE_FAMILY = "1,2"; 313 | }; 314 | name = Release; 315 | }; 316 | /* End XCBuildConfiguration section */ 317 | 318 | /* Begin XCConfigurationList section */ 319 | 71AE686A1F49B2DD00196F80 /* Build configuration list for PBXProject "BadgeControl" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 71AE68761F49B2DD00196F80 /* Debug */, 323 | 71AE68771F49B2DD00196F80 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | 71AE68781F49B2DD00196F80 /* Build configuration list for PBXNativeTarget "BadgeControl" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 71AE68791F49B2DD00196F80 /* Debug */, 332 | 71AE687A1F49B2DD00196F80 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | /* End XCConfigurationList section */ 338 | }; 339 | rootObject = 71AE68671F49B2DD00196F80 /* Project object */; 340 | } 341 | -------------------------------------------------------------------------------- /BadgeControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BadgeControl.xcodeproj/project.xcworkspace/xcuserdata/robinkrenecky.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/BadgeControl.xcodeproj/project.xcworkspace/xcuserdata/robinkrenecky.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BadgeControl.xcodeproj/xcshareddata/xcschemes/BadgeControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 72 | 73 | 74 | 75 | 77 | 78 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /BadgeControl.xcodeproj/xcuserdata/robinkrenecky.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BadgeControl.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 71AE686F1F49B2DD00196F80 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /BadgeControl/BadgeAnimations.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeAnimations.swift 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 21.08.17. 6 | // 7 | 8 | import Foundation 9 | 10 | public typealias BadgeAnimation = (UIView) -> Void 11 | 12 | public struct BadgeAnimations { 13 | 14 | public static var defaultAnimation: BadgeAnimation = { badgeView in 15 | badgeView.transform = CGAffineTransform(scaleX: 2.7, y: 2.7) 16 | UIView.animate( 17 | withDuration: 0.5, 18 | delay: 0, 19 | usingSpringWithDamping: 0.5, 20 | initialSpringVelocity: 0.5, 21 | options: .curveEaseIn, 22 | animations: { badgeView.transform = CGAffineTransform.identity }, 23 | completion: nil) 24 | } 25 | 26 | public static var leftRight: BadgeAnimation = { badgeView in 27 | let travelDistance = badgeView.frame.width * 1.5 28 | badgeView.center.x -= travelDistance 29 | UIView.animate( 30 | withDuration: 0.5, 31 | delay: 0, 32 | usingSpringWithDamping: 0.5, 33 | initialSpringVelocity: 0.5, 34 | options: .curveEaseOut, 35 | animations: { badgeView.center.x += travelDistance }, 36 | completion: nil) 37 | } 38 | 39 | public static var rightLeft: BadgeAnimation = { badgeView in 40 | let travelDistance = badgeView.frame.width * 1.5 41 | badgeView.center.x += travelDistance 42 | UIView.animate( 43 | withDuration: 0.5, 44 | delay: 0, 45 | usingSpringWithDamping: 0.5, 46 | initialSpringVelocity: 0.5, 47 | options: .curveEaseOut, 48 | animations: { badgeView.center.x -= travelDistance }, 49 | completion: nil) 50 | } 51 | 52 | public static var fadeIn: BadgeAnimation = { badgeView in 53 | badgeView.alpha = 0 54 | UIView.animate( 55 | withDuration: 1.5, 56 | delay: 0, 57 | usingSpringWithDamping: 1, 58 | initialSpringVelocity: 0.1, 59 | options: .curveEaseIn, 60 | animations: { badgeView.alpha = 1 }, 61 | completion: nil) 62 | } 63 | 64 | public static var rolling: BadgeAnimation = { badgeView in 65 | badgeView.transform = CGAffineTransform(rotationAngle: .pi) 66 | UIView.animate( 67 | withDuration: 0.5, 68 | delay: 0, 69 | usingSpringWithDamping: 1, 70 | initialSpringVelocity: 0.5, 71 | options: .curveEaseIn, 72 | animations: { badgeView.transform = CGAffineTransform.identity }, 73 | completion: nil) 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /BadgeControl/BadgeCenterPosition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CenterPosition.swift 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 19.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public enum BadgeCenterPosition { 12 | case upperLeftCorner 13 | case upperRightCorner 14 | case lowerLeftCorner 15 | case lowerRightCorner 16 | case custom(x: Double, y: Double) 17 | 18 | public func centerPoint(in view: UIView) -> CGPoint { 19 | switch self { 20 | case .upperLeftCorner: 21 | return CGPoint(x: 0, y: 0) 22 | case .upperRightCorner: 23 | return CGPoint(x: view.frame.width, y: 0) 24 | case .lowerLeftCorner: 25 | return CGPoint(x: 0, y: view.frame.height) 26 | case .lowerRightCorner: 27 | return CGPoint(x: view.frame.width, y: view.frame.height) 28 | case .custom(let x, let y): 29 | return CGPoint(x: x, y: y) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BadgeControl/BadgeControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeControl.h 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 20.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | FOUNDATION_EXPORT double BadgeControlVersionNumber; 12 | FOUNDATION_EXPORT const unsigned char BadgeControlVersionString[]; 13 | 14 | -------------------------------------------------------------------------------- /BadgeControl/BadgeController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeController.swift 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 19.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | open class BadgeController { 12 | 13 | // MARK: Public properties 14 | 15 | public var centerPosition: BadgeCenterPosition 16 | public var badgeBackgroundColor: UIColor { didSet { currentBadge?.badgeBackgroundColor = badgeBackgroundColor } } 17 | public var badgeTextColor: UIColor { didSet { currentBadge?.badgeTextColor = badgeTextColor } } 18 | public var badgeTextFont: UIFont { didSet { currentBadge?.badgeTextFont = badgeTextFont } } 19 | public var borderWidth: CGFloat { didSet { currentBadge?.borderWidth = borderWidth } } 20 | public var borderColor: UIColor { didSet { currentBadge?.borderColor = borderColor } } 21 | public var badgeHeight: CGFloat { didSet { currentBadge?.height = badgeHeight + borderWidth * 2 } } 22 | public var currentBadge: BadgeView? 23 | public var animation: ((UIView) -> Void)? 24 | 25 | public var animateOnlyWhenBadgeIsNotYetPresent: Bool 26 | 27 | // MARK: Private properties 28 | 29 | private weak var view: UIView? 30 | private var counter: Int? 31 | private var currentText = "" { didSet { currentBadge?.text = currentText } } 32 | private var centerPositionCGPoint: CGPoint? { 33 | guard let view = view else { return nil } 34 | return centerPosition.centerPoint(in: view) 35 | } 36 | private var isPerformingRemoveAnimation = false 37 | 38 | // MARK: Initializers 39 | 40 | public init(for view: UIView, 41 | in centerPosition: BadgeCenterPosition = .upperRightCorner, 42 | badgeBackgroundColor: UIColor = .red, 43 | badgeTextColor: UIColor = .white, 44 | badgeTextFont: UIFont? = nil, 45 | borderWidth: CGFloat = 0.0, 46 | borderColor: UIColor = .black, 47 | animation: BadgeAnimation? = BadgeAnimations.defaultAnimation, 48 | badgeHeight: CGFloat? = nil, 49 | animateOnlyWhenBadgeIsNotYetPresent: Bool = false) { 50 | 51 | self.view = view 52 | self.centerPosition = centerPosition 53 | self.badgeBackgroundColor = badgeBackgroundColor 54 | self.badgeTextColor = badgeTextColor 55 | self.borderWidth = borderWidth 56 | self.borderColor = borderColor 57 | self.animation = animation 58 | self.animateOnlyWhenBadgeIsNotYetPresent = animateOnlyWhenBadgeIsNotYetPresent 59 | 60 | if let badgeHeight = badgeHeight { 61 | self.badgeHeight = badgeHeight 62 | } else { 63 | self.badgeHeight = view.frame.height / 1.35 64 | } 65 | 66 | if let badgeTextFont = badgeTextFont { 67 | self.badgeTextFont = badgeTextFont 68 | } else { 69 | self.badgeTextFont = UIFont.systemFont(ofSize: CGFloat(self.badgeHeight) * 23 / 32) 70 | } 71 | } 72 | 73 | // MARK: Public methods 74 | 75 | public func addOrReplaceCurrent(with text: String? = nil, animated: Bool) { 76 | if isPerformingRemoveAnimation { 77 | remove(animated: false) 78 | isPerformingRemoveAnimation = false 79 | } 80 | 81 | let animated = animated && !(currentBadge != nil && animateOnlyWhenBadgeIsNotYetPresent) 82 | 83 | currentText = text ?? "" 84 | counter = Int(currentText) 85 | addBadgeIfNeeded() 86 | 87 | guard let currentBadge = currentBadge else { return } 88 | if animated { animation?(currentBadge) } 89 | } 90 | 91 | public func remove(animated: Bool) { 92 | if animated, let currentBadge = currentBadge { 93 | removeBadgeWithAnimation(currentBadge) 94 | return 95 | } 96 | 97 | currentBadge?.removeFromSuperview() 98 | currentBadge = nil 99 | currentText = "" 100 | counter = nil 101 | } 102 | 103 | public func increment(animated: Bool) { 104 | if isPerformingRemoveAnimation { 105 | remove(animated: false) 106 | isPerformingRemoveAnimation = false 107 | } 108 | 109 | if currentBadge != nil { 110 | guard let counter = counter else { 111 | print("Cannot increment non-numeric value") 112 | return 113 | } 114 | addOrReplaceCurrent(with: "\(counter + 1)", animated: animated) 115 | } else { 116 | addOrReplaceCurrent(with: "1", animated: animated) 117 | } 118 | } 119 | 120 | public func decrement(animated: Bool) { 121 | if isPerformingRemoveAnimation { 122 | remove(animated: false) 123 | isPerformingRemoveAnimation = false 124 | } 125 | 126 | if currentBadge != nil { 127 | guard let counter = counter else { 128 | print("Cannot decrement non-numeric value") 129 | return 130 | } 131 | if counter > 1 { 132 | addOrReplaceCurrent(with: "\(counter - 1)", animated: animated) 133 | } else { 134 | remove(animated: animated) 135 | } 136 | } 137 | } 138 | 139 | private func addBadgeIfNeeded() { 140 | guard currentBadge == nil, let centerPositionPoint = centerPositionCGPoint else { 141 | return 142 | } 143 | 144 | let badgeView = BadgeView(height: badgeHeight + borderWidth * 2, 145 | center: centerPositionPoint, 146 | text: currentText, 147 | badgeBackgroundColor: badgeBackgroundColor, 148 | badgeTextColor: badgeTextColor, 149 | badgeTextFont: badgeTextFont, 150 | borderWidth: borderWidth, 151 | borderColor: borderColor) 152 | 153 | currentBadge = badgeView 154 | view?.addSubview(badgeView) 155 | } 156 | 157 | private func removeBadgeWithAnimation(_ badge: BadgeView) { 158 | guard !isPerformingRemoveAnimation else { return } 159 | 160 | isPerformingRemoveAnimation = true 161 | UIView.animate( 162 | withDuration: 0.7, 163 | delay: 0, 164 | usingSpringWithDamping: 1, 165 | initialSpringVelocity: 0.3, 166 | options: .curveLinear, 167 | animations: { 168 | badge.transform = CGAffineTransform(scaleX: 0.01, y: 0.01) 169 | badge.alpha = 0 170 | }, 171 | completion: { _ in 172 | if self.isPerformingRemoveAnimation { 173 | self.isPerformingRemoveAnimation = false 174 | self.remove(animated: false) 175 | } 176 | } 177 | ) 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /BadgeControl/BadgeView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeView.swift 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 19.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | open class BadgeView: UIView { 12 | 13 | // MARK: Internal properties 14 | 15 | internal var height: CGFloat { didSet { updateUI() } } 16 | internal var centerPoint: CGPoint { didSet { updateUI() } } 17 | internal var text: String { didSet { updateUI() } } 18 | internal var badgeBackgroundColor: UIColor { didSet { updateUI() } } 19 | internal var badgeTextColor: UIColor { didSet { updateUI() } } 20 | internal var badgeTextFont: UIFont { didSet { updateUI() } } 21 | internal var borderWidth: CGFloat { didSet { updateUI() } } 22 | internal var borderColor: UIColor { didSet { updateUI() } } 23 | 24 | // MARK: Initializers 25 | 26 | public init(height: CGFloat, 27 | center: CGPoint, 28 | text: String, 29 | badgeBackgroundColor: UIColor, 30 | badgeTextColor: UIColor, 31 | badgeTextFont: UIFont, 32 | borderWidth: CGFloat, 33 | borderColor: UIColor) { 34 | 35 | self.height = height 36 | self.centerPoint = center 37 | self.text = text 38 | self.badgeBackgroundColor = badgeBackgroundColor 39 | self.badgeTextColor = badgeTextColor 40 | self.badgeTextFont = badgeTextFont 41 | self.borderWidth = borderWidth 42 | self.borderColor = borderColor 43 | 44 | super.init(frame: CGRect(x: 0, 45 | y: 0, 46 | width: BadgeView.calculateWidth(height: height, borderWidth: borderWidth, text: text), 47 | height: height)) 48 | 49 | backgroundColor = .clear 50 | } 51 | 52 | @available(*, unavailable, message: "Storyboard initiation is not supported.") 53 | public required init?(coder aDecoder: NSCoder) { fatalError("Not supported") } 54 | 55 | open override func draw(_ rect: CGRect) { 56 | frame = CGRect(x: 0, y: 0, width: BadgeView.calculateWidth(height: height, borderWidth: borderWidth, text: text), height: height) 57 | let height = frame.height - borderWidth 58 | let ovalWidth = height 59 | let rightHemisphereX = frame.width - borderWidth / 2 - height 60 | 61 | drawOval(height, ovalWidth, rightHemisphereX) 62 | drawText() 63 | center = centerPoint 64 | } 65 | 66 | // MARK: Private methods 67 | 68 | private static func calculateWidth(height: CGFloat, borderWidth: CGFloat, text: String) -> CGFloat { 69 | let height = height - borderWidth * 2 70 | let ratio = CGFloat(text.count > 0 ? text.count : 1) 71 | return CGFloat(height + (ratio - 1) * height / 2.4) + borderWidth * 2 72 | } 73 | 74 | private func drawOval(_ height: CGFloat, _ ovalWidth: CGFloat, _ rightHemisphereX: CGFloat) { 75 | var ovalPath = UIBezierPath() 76 | 77 | addRightHemisphereArc(to: &ovalPath, rightHemisphereX, ovalWidth, height) 78 | ovalPath.addLine(to: CGPoint(x: ovalWidth / 2, y: height + borderWidth / 2)) 79 | addLeftHemisphereArc(to: &ovalPath, frame, ovalWidth, height) 80 | ovalPath.close() 81 | 82 | badgeBackgroundColor.setFill() 83 | ovalPath.fill() 84 | 85 | borderColor.setStroke() 86 | ovalPath.lineWidth = borderWidth 87 | ovalPath.stroke() 88 | } 89 | 90 | private func addRightHemisphereArc(to path: inout UIBezierPath, _ rightHemisphereX: CGFloat, _ ovalWidth: CGFloat, _ height: CGFloat) { 91 | let rightHemisphereRect = CGRect(x: rightHemisphereX, y: borderWidth / 2, width: ovalWidth, height: height) 92 | 93 | path.addArc(withCenter: CGPoint(x: rightHemisphereRect.midX, y: rightHemisphereRect.midY), 94 | radius: rightHemisphereRect.width / 2, 95 | startAngle: -90 * CGFloat.pi / 180, 96 | endAngle: -270 * CGFloat.pi / 180, 97 | clockwise: true) 98 | } 99 | 100 | private func addLeftHemisphereArc(to path: inout UIBezierPath, _ frame: CGRect, _ ovalWidth: CGFloat, _ height: CGFloat) { 101 | let leftHemisphereRect = CGRect(x: frame.minX + borderWidth / 2, y: frame.minY + borderWidth / 2, width: ovalWidth, height: height) 102 | 103 | path.addArc(withCenter: CGPoint(x: leftHemisphereRect.midX, y: leftHemisphereRect.midY), 104 | radius: leftHemisphereRect.width / 2, 105 | startAngle: -270 * CGFloat.pi / 180, 106 | endAngle: -90 * CGFloat.pi / 180, 107 | clockwise: true) 108 | } 109 | 110 | private func drawText() { 111 | let textRect = frame 112 | let textTextContent = text 113 | let textStyle = NSMutableParagraphStyle() 114 | textStyle.alignment = .center 115 | let textFontAttributes = [ 116 | .font: badgeTextFont, 117 | .foregroundColor: badgeTextColor, 118 | .paragraphStyle: textStyle, 119 | ] as [NSAttributedString.Key: Any] 120 | 121 | let textTextHeight: CGFloat = textTextContent.boundingRect(with: CGSize(width: textRect.width, height: CGFloat.infinity), 122 | options: .usesLineFragmentOrigin, 123 | attributes: textFontAttributes, 124 | context: nil).height 125 | 126 | textTextContent.draw(in: CGRect(x: textRect.minX, y: textRect.minY + (textRect.height - textTextHeight) / 2, 127 | width: textRect.width, 128 | height: textTextHeight), 129 | withAttributes: textFontAttributes) 130 | } 131 | 132 | private func updateUI() { 133 | setNeedsDisplay() 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /BadgeControl/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3542CEA3B8769134580D667F /* Pods_BadgeControlExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 975133B2BE1D88596CF0ACED /* Pods_BadgeControlExample.framework */; }; 11 | 711AE8C51F49BF8700E3FF42 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 712894451F49B47700C03939 /* Main.storyboard */; }; 12 | 712894321F49B44E00C03939 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712894311F49B44E00C03939 /* AppDelegate.swift */; }; 13 | 712894391F49B44E00C03939 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 712894381F49B44E00C03939 /* Assets.xcassets */; }; 14 | 7128943C1F49B44E00C03939 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7128943A1F49B44E00C03939 /* LaunchScreen.storyboard */; }; 15 | 712894441F49B46500C03939 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712894431F49B46500C03939 /* ViewController.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 470987EC86742660EB0D28A0 /* Pods-BadgeControlExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BadgeControlExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BadgeControlExample/Pods-BadgeControlExample.debug.xcconfig"; sourceTree = ""; }; 20 | 7128942E1F49B44E00C03939 /* BadgeControlExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BadgeControlExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 712894311F49B44E00C03939 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 712894381F49B44E00C03939 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 7128943B1F49B44E00C03939 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 7128943D1F49B44E00C03939 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | 712894431F49B46500C03939 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 26 | 712894451F49B47700C03939 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 27 | 975133B2BE1D88596CF0ACED /* Pods_BadgeControlExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BadgeControlExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 9E9D5E58C1E1C44CB3FDA048 /* Pods-BadgeControlExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BadgeControlExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-BadgeControlExample/Pods-BadgeControlExample.release.xcconfig"; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 7128942B1F49B44E00C03939 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | 3542CEA3B8769134580D667F /* Pods_BadgeControlExample.framework in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 39CB20DD92B23CFB66BA295B /* Pods */ = { 44 | isa = PBXGroup; 45 | children = ( 46 | 470987EC86742660EB0D28A0 /* Pods-BadgeControlExample.debug.xcconfig */, 47 | 9E9D5E58C1E1C44CB3FDA048 /* Pods-BadgeControlExample.release.xcconfig */, 48 | ); 49 | name = Pods; 50 | sourceTree = ""; 51 | }; 52 | 712894251F49B44E00C03939 = { 53 | isa = PBXGroup; 54 | children = ( 55 | 712894301F49B44E00C03939 /* BadgeControlExample */, 56 | 7128942F1F49B44E00C03939 /* Products */, 57 | 39CB20DD92B23CFB66BA295B /* Pods */, 58 | 80431E22E2A7B2EEE21D1609 /* Frameworks */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 7128942F1F49B44E00C03939 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 7128942E1F49B44E00C03939 /* BadgeControlExample.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | 712894301F49B44E00C03939 /* BadgeControlExample */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 712894311F49B44E00C03939 /* AppDelegate.swift */, 74 | 712894431F49B46500C03939 /* ViewController.swift */, 75 | 712894451F49B47700C03939 /* Main.storyboard */, 76 | 712894381F49B44E00C03939 /* Assets.xcassets */, 77 | 7128943A1F49B44E00C03939 /* LaunchScreen.storyboard */, 78 | 7128943D1F49B44E00C03939 /* Info.plist */, 79 | ); 80 | path = BadgeControlExample; 81 | sourceTree = ""; 82 | }; 83 | 80431E22E2A7B2EEE21D1609 /* Frameworks */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 975133B2BE1D88596CF0ACED /* Pods_BadgeControlExample.framework */, 87 | ); 88 | name = Frameworks; 89 | sourceTree = ""; 90 | }; 91 | /* End PBXGroup section */ 92 | 93 | /* Begin PBXNativeTarget section */ 94 | 7128942D1F49B44E00C03939 /* BadgeControlExample */ = { 95 | isa = PBXNativeTarget; 96 | buildConfigurationList = 712894401F49B44E00C03939 /* Build configuration list for PBXNativeTarget "BadgeControlExample" */; 97 | buildPhases = ( 98 | 93868D542A4863814E9D072B /* [CP] Check Pods Manifest.lock */, 99 | 7128942A1F49B44E00C03939 /* Sources */, 100 | 7128942B1F49B44E00C03939 /* Frameworks */, 101 | 7128942C1F49B44E00C03939 /* Resources */, 102 | E21D384D7D3EE444C77D050A /* [CP] Embed Pods Frameworks */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = BadgeControlExample; 109 | productName = BadgeControlExample; 110 | productReference = 7128942E1F49B44E00C03939 /* BadgeControlExample.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | 712894261F49B44E00C03939 /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastSwiftUpdateCheck = 0900; 120 | LastUpgradeCheck = 0900; 121 | ORGANIZATIONNAME = "Robin Krenecky"; 122 | TargetAttributes = { 123 | 7128942D1F49B44E00C03939 = { 124 | CreatedOnToolsVersion = 9.0; 125 | ProvisioningStyle = Manual; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = 712894291F49B44E00C03939 /* Build configuration list for PBXProject "BadgeControlExample" */; 130 | compatibilityVersion = "Xcode 8.0"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = 712894251F49B44E00C03939; 138 | productRefGroup = 7128942F1F49B44E00C03939 /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | 7128942D1F49B44E00C03939 /* BadgeControlExample */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | 7128942C1F49B44E00C03939 /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 711AE8C51F49BF8700E3FF42 /* Main.storyboard in Resources */, 153 | 7128943C1F49B44E00C03939 /* LaunchScreen.storyboard in Resources */, 154 | 712894391F49B44E00C03939 /* Assets.xcassets in Resources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXResourcesBuildPhase section */ 159 | 160 | /* Begin PBXShellScriptBuildPhase section */ 161 | 93868D542A4863814E9D072B /* [CP] Check Pods Manifest.lock */ = { 162 | isa = PBXShellScriptBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | ); 166 | inputPaths = ( 167 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 168 | "${PODS_ROOT}/Manifest.lock", 169 | ); 170 | name = "[CP] Check Pods Manifest.lock"; 171 | outputPaths = ( 172 | "$(DERIVED_FILE_DIR)/Pods-BadgeControlExample-checkManifestLockResult.txt", 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | shellPath = /bin/sh; 176 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 177 | showEnvVarsInLog = 0; 178 | }; 179 | E21D384D7D3EE444C77D050A /* [CP] Embed Pods Frameworks */ = { 180 | isa = PBXShellScriptBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | ); 184 | inputPaths = ( 185 | "${PODS_ROOT}/Target Support Files/Pods-BadgeControlExample/Pods-BadgeControlExample-frameworks.sh", 186 | "${BUILT_PRODUCTS_DIR}/BadgeControl/BadgeControl.framework", 187 | ); 188 | name = "[CP] Embed Pods Frameworks"; 189 | outputPaths = ( 190 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BadgeControl.framework", 191 | ); 192 | runOnlyForDeploymentPostprocessing = 0; 193 | shellPath = /bin/sh; 194 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BadgeControlExample/Pods-BadgeControlExample-frameworks.sh\"\n"; 195 | showEnvVarsInLog = 0; 196 | }; 197 | /* End PBXShellScriptBuildPhase section */ 198 | 199 | /* Begin PBXSourcesBuildPhase section */ 200 | 7128942A1F49B44E00C03939 /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | 712894441F49B46500C03939 /* ViewController.swift in Sources */, 205 | 712894321F49B44E00C03939 /* AppDelegate.swift in Sources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | /* End PBXSourcesBuildPhase section */ 210 | 211 | /* Begin PBXVariantGroup section */ 212 | 7128943A1F49B44E00C03939 /* LaunchScreen.storyboard */ = { 213 | isa = PBXVariantGroup; 214 | children = ( 215 | 7128943B1F49B44E00C03939 /* Base */, 216 | ); 217 | name = LaunchScreen.storyboard; 218 | sourceTree = ""; 219 | }; 220 | /* End PBXVariantGroup section */ 221 | 222 | /* Begin XCBuildConfiguration section */ 223 | 7128943E1F49B44E00C03939 /* Debug */ = { 224 | isa = XCBuildConfiguration; 225 | buildSettings = { 226 | ALWAYS_SEARCH_USER_PATHS = NO; 227 | CLANG_ANALYZER_NONNULL = YES; 228 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 229 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 230 | CLANG_CXX_LIBRARY = "libc++"; 231 | CLANG_ENABLE_MODULES = YES; 232 | CLANG_ENABLE_OBJC_ARC = YES; 233 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 234 | CLANG_WARN_BOOL_CONVERSION = YES; 235 | CLANG_WARN_COMMA = YES; 236 | CLANG_WARN_CONSTANT_CONVERSION = YES; 237 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 238 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 239 | CLANG_WARN_EMPTY_BODY = YES; 240 | CLANG_WARN_ENUM_CONVERSION = YES; 241 | CLANG_WARN_INFINITE_RECURSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 244 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 245 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 246 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 247 | CLANG_WARN_STRICT_PROTOTYPES = YES; 248 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 249 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 250 | CLANG_WARN_UNREACHABLE_CODE = YES; 251 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 252 | CODE_SIGN_IDENTITY = "iPhone Developer"; 253 | COPY_PHASE_STRIP = NO; 254 | DEBUG_INFORMATION_FORMAT = dwarf; 255 | ENABLE_STRICT_OBJC_MSGSEND = YES; 256 | ENABLE_TESTABILITY = YES; 257 | GCC_C_LANGUAGE_STANDARD = gnu11; 258 | GCC_DYNAMIC_NO_PIC = NO; 259 | GCC_NO_COMMON_BLOCKS = YES; 260 | GCC_OPTIMIZATION_LEVEL = 0; 261 | GCC_PREPROCESSOR_DEFINITIONS = ( 262 | "DEBUG=1", 263 | "$(inherited)", 264 | ); 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 272 | MTL_ENABLE_DEBUG_INFO = YES; 273 | ONLY_ACTIVE_ARCH = YES; 274 | SDKROOT = iphoneos; 275 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 276 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 277 | SWIFT_VERSION = 5.0; 278 | }; 279 | name = Debug; 280 | }; 281 | 7128943F1F49B44E00C03939 /* Release */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ALWAYS_SEARCH_USER_PATHS = NO; 285 | CLANG_ANALYZER_NONNULL = YES; 286 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 287 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 288 | CLANG_CXX_LIBRARY = "libc++"; 289 | CLANG_ENABLE_MODULES = YES; 290 | CLANG_ENABLE_OBJC_ARC = YES; 291 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 292 | CLANG_WARN_BOOL_CONVERSION = YES; 293 | CLANG_WARN_COMMA = YES; 294 | CLANG_WARN_CONSTANT_CONVERSION = YES; 295 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 296 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 297 | CLANG_WARN_EMPTY_BODY = YES; 298 | CLANG_WARN_ENUM_CONVERSION = YES; 299 | CLANG_WARN_INFINITE_RECURSION = YES; 300 | CLANG_WARN_INT_CONVERSION = YES; 301 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 302 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 303 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 304 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 305 | CLANG_WARN_STRICT_PROTOTYPES = YES; 306 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 307 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 308 | CLANG_WARN_UNREACHABLE_CODE = YES; 309 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 310 | CODE_SIGN_IDENTITY = "iPhone Developer"; 311 | COPY_PHASE_STRIP = NO; 312 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 313 | ENABLE_NS_ASSERTIONS = NO; 314 | ENABLE_STRICT_OBJC_MSGSEND = YES; 315 | GCC_C_LANGUAGE_STANDARD = gnu11; 316 | GCC_NO_COMMON_BLOCKS = YES; 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 324 | MTL_ENABLE_DEBUG_INFO = NO; 325 | SDKROOT = iphoneos; 326 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 327 | SWIFT_VERSION = 5.0; 328 | VALIDATE_PRODUCT = YES; 329 | }; 330 | name = Release; 331 | }; 332 | 712894411F49B44E00C03939 /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | baseConfigurationReference = 470987EC86742660EB0D28A0 /* Pods-BadgeControlExample.debug.xcconfig */; 335 | buildSettings = { 336 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 337 | CODE_SIGN_STYLE = Manual; 338 | DEVELOPMENT_TEAM = ""; 339 | INFOPLIST_FILE = BadgeControlExample/Info.plist; 340 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 341 | PRODUCT_BUNDLE_IDENTIFIER = cz.kiwisip.BadgeControlExample; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | PROVISIONING_PROFILE_SPECIFIER = ""; 344 | SWIFT_VERSION = 5.0; 345 | TARGETED_DEVICE_FAMILY = "1,2"; 346 | }; 347 | name = Debug; 348 | }; 349 | 712894421F49B44E00C03939 /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | baseConfigurationReference = 9E9D5E58C1E1C44CB3FDA048 /* Pods-BadgeControlExample.release.xcconfig */; 352 | buildSettings = { 353 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 354 | CODE_SIGN_STYLE = Manual; 355 | DEVELOPMENT_TEAM = ""; 356 | INFOPLIST_FILE = BadgeControlExample/Info.plist; 357 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 358 | PRODUCT_BUNDLE_IDENTIFIER = cz.kiwisip.BadgeControlExample; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | PROVISIONING_PROFILE_SPECIFIER = ""; 361 | SWIFT_VERSION = 5.0; 362 | TARGETED_DEVICE_FAMILY = "1,2"; 363 | }; 364 | name = Release; 365 | }; 366 | /* End XCBuildConfiguration section */ 367 | 368 | /* Begin XCConfigurationList section */ 369 | 712894291F49B44E00C03939 /* Build configuration list for PBXProject "BadgeControlExample" */ = { 370 | isa = XCConfigurationList; 371 | buildConfigurations = ( 372 | 7128943E1F49B44E00C03939 /* Debug */, 373 | 7128943F1F49B44E00C03939 /* Release */, 374 | ); 375 | defaultConfigurationIsVisible = 0; 376 | defaultConfigurationName = Release; 377 | }; 378 | 712894401F49B44E00C03939 /* Build configuration list for PBXNativeTarget "BadgeControlExample" */ = { 379 | isa = XCConfigurationList; 380 | buildConfigurations = ( 381 | 712894411F49B44E00C03939 /* Debug */, 382 | 712894421F49B44E00C03939 /* Release */, 383 | ); 384 | defaultConfigurationIsVisible = 0; 385 | defaultConfigurationName = Release; 386 | }; 387 | /* End XCConfigurationList section */ 388 | }; 389 | rootObject = 712894261F49B44E00C03939 /* Project object */; 390 | } 391 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample.xcodeproj/project.xcworkspace/xcuserdata/robinkrenecky.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/BadgeControlExample/BadgeControlExample.xcodeproj/project.xcworkspace/xcuserdata/robinkrenecky.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample.xcodeproj/xcuserdata/robinkrenecky.xcuserdatad/xcschemes/BadgeControlExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample.xcodeproj/xcuserdata/robinkrenecky.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BadgeControlExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7128942D1F49B44E00C03939 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BadgeControlExample 4 | // 5 | // Created by Robin Krenecky on 20.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | func application(_ application: UIApplication, 16 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Assets.xcassets/Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "iconmonstr-speech-bubble-30-240.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Assets.xcassets/Image.imageset/iconmonstr-speech-bubble-30-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/BadgeControlExample/BadgeControlExample/Assets.xcassets/Image.imageset/iconmonstr-speech-bubble-30-240.png -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/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 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 32 | 44 | 56 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /BadgeControlExample/BadgeControlExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BadgeControl 4 | // 5 | // Created by Robin Krenecky on 19.08.17. 6 | // Copyright © 2017 Robin Krenecky. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import BadgeControl 11 | 12 | class ViewController: UIViewController, UITextFieldDelegate { 13 | 14 | @IBOutlet weak var imageView: UIImageView! 15 | @IBOutlet weak var badgeTitleTextField: UITextField! 16 | 17 | private var upperLeftBadge: BadgeController! 18 | private var upperRightBadge: BadgeController! 19 | private var lowerLeftBadge: BadgeController! 20 | private var lowerRightBadge: BadgeController! 21 | 22 | private var badges: [BadgeController] = [] 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | badgeTitleTextField.delegate = self 28 | 29 | upperLeftBadge = BadgeController(for: imageView, 30 | in: .upperLeftCorner, 31 | badgeBackgroundColor: UIColor.blue, 32 | badgeTextColor: UIColor.yellow, 33 | badgeHeight: 30) 34 | upperLeftBadge.animateOnlyWhenBadgeIsNotYetPresent = true 35 | 36 | upperRightBadge = BadgeController(for: imageView) 37 | lowerLeftBadge = BadgeController(for: imageView, 38 | in: .lowerLeftCorner, 39 | badgeBackgroundColor: UIColor.purple, 40 | badgeTextColor: UIColor.cyan) 41 | lowerRightBadge = BadgeController(for: imageView, 42 | in: .lowerRightCorner, 43 | badgeBackgroundColor: UIColor.white, 44 | badgeTextColor: UIColor.black, 45 | borderWidth: 6, 46 | borderColor: UIColor.black, 47 | badgeHeight: 30) 48 | 49 | badges = [upperLeftBadge, upperRightBadge, lowerLeftBadge, lowerRightBadge] 50 | } 51 | 52 | @IBAction func changeAnimation(_ sender: UISegmentedControl) { 53 | guard let title = sender.titleForSegment(at: sender.selectedSegmentIndex) else { return } 54 | 55 | switch title { 56 | case "default": badges.forEach { $0.animation = BadgeAnimations.defaultAnimation } 57 | case "leftRight": badges.forEach { $0.animation = BadgeAnimations.leftRight } 58 | case "rightLeft": badges.forEach { $0.animation = BadgeAnimations.rightLeft } 59 | case "fadeIn": badges.forEach { $0.animation = BadgeAnimations.fadeIn } 60 | case "roll": badges.forEach { $0.animation = BadgeAnimations.rolling } 61 | default: return 62 | } 63 | } 64 | 65 | @IBAction func add(_ sender: UIButton) { 66 | guard let text = badgeTitleTextField.text, text != "" else { return } 67 | badges.forEach { $0.addOrReplaceCurrent(with: text, animated: true) } 68 | } 69 | 70 | @IBAction func remove(_ sender: UIButton) { 71 | badges.forEach { $0.remove(animated: true) } 72 | } 73 | 74 | @IBAction func increment(_ sender: UIButton) { 75 | badges.forEach { $0.increment(animated: true) } 76 | } 77 | 78 | @IBAction func decrement(_ sender: UIButton) { 79 | badges.forEach { $0.decrement(animated: true) } 80 | } 81 | 82 | func textFieldShouldReturn(_ textField: UITextField) -> Bool { 83 | textField.resignFirstResponder() 84 | return true 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /BadgeControlExample/Podfile: -------------------------------------------------------------------------------- 1 | target 'BadgeControlExample' do 2 | use_frameworks! 3 | 4 | pod 'BadgeControl', :path => '../' 5 | end 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2017 Robin Krenecky 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | defaultboomall 2 | 3 | # BadgeControl 4 | * Simply attach BadgeController to any UIView's subclasses and easily control the badge. 5 | * Customize size, position, background color, text color, border width, border color and animation of the badge. 6 | 7 | ## Setup 8 | #### Setup with CocoaPods (iOS 9+) 9 | * If you are using CocoaPods add this text to your Podfile and run `pod install`. 10 | 11 | ~~~ruby 12 | pod 'BadgeControl' 13 | ~~~ 14 | #### Add source (iOS 9+) 15 | * Add [BadgeController.swift](https://github.com/kiwisip/BadgeControl/blob/master/BadgeControl/BadgeController.swift), [BadgeView.swift](https://github.com/kiwisip/BadgeControl/blob/master/BadgeControl/BadgeView.swift), [BadgeCenterPosition.swift](https://github.com/kiwisip/BadgeControl/blob/master/BadgeControl/BadgeCenterPosition.swift) and [BadgeAnimations.swift](https://github.com/kiwisip/BadgeControl/blob/master/BadgeControl/BadgeAnimations.swift) to your project. 16 | 17 | ## Usage 18 | Add `import BadgeControl` to your source code (unless you used the file setup method).

19 | Simply attach BadgeController to your UIView (or its subclass). 20 | 21 | ~~~swift 22 | let badge = BadgeController(for: myUIView) 23 | ~~~ 24 | 25 | Add an empty badge and present it with animation. 26 | 27 | ~~~swift 28 | badge.addOrReplaceCurrent(animated: true) 29 | ~~~ 30 | 31 | Add a badge with text and present it with animation. 32 | 33 | ~~~swift 34 | badge.addOrReplaceCurrent(with: "1", animated: true) 35 | ~~~ 36 | 37 | Remove badge from its view. 38 | 39 | ~~~swift 40 | badge.remove(animated: true) 41 | ~~~ 42 | 43 | Simply increment or decrement the value on your badge (if it is numeric) and present it with animation. 44 | 45 | ~~~swift 46 | badge.increment(animated: true) 47 | badge.decrement(animated: true) 48 | ~~~ 49 | 50 | You can also set `animateOnlyWhenBadgeIsNotYetPresent = true` if you don't want animation when badge is already present on the view. 51 | 52 | 53 | ## Customization 54 | You can customize badge's text font, background color, text color, border width, border color, size, center position and animation. 55 | 56 | #### Text font, background color, text color, border width, border color and size 57 | ~~~swift 58 | badge.badgeTextFont = UIFont.systemFont(ofSize: 15) 59 | badge.badgeBackgroundColor = UIColor.blue 60 | badge.badgeTextColor = UIColor.yellow 61 | badge.borderWidth = 3 // in px 62 | badge.borderColor = UIColor.black // black is default 63 | badge.badgeHeight = 20 // badge will have height of 20px 64 | ~~~ 65 | 66 | #### Center position 67 | You can choose following center positions: upperLeftCorner, upperRightCorner, lowerLeftCorner, lowerRightCorner. 68 | 69 | You can also choose custom position by calling .custom(x: Double, y: Double). 70 | 71 | ~~~swift 72 | badge.centerPosition = .upperLeftCorner 73 | badge.centerPosition = .custom(x: 10, y: 20) 74 | ~~~ 75 | 76 | #### Animations 77 | You can choose one of the following animations: 78 | 79 | ###### Default animation 80 | default 81 | 82 | ~~~swift 83 | badge.animation = BadgeAnimations.default 84 | ~~~ 85 | 86 | ###### Left-right animation 87 | default 88 | 89 | ~~~swift 90 | badge.animation = BadgeAnimations.leftRight 91 | ~~~ 92 | 93 | ###### Right-left animation 94 | default 95 | 96 | ~~~swift 97 | badge.animation = BadgeAnimations.rightLeft 98 | ~~~ 99 | 100 | ###### Fade in animation 101 | default 102 | 103 | ~~~swift 104 | badge.animation = BadgeAnimations.fadeIn 105 | ~~~ 106 | 107 | ###### Rolling animation 108 | default 109 | 110 | ~~~swift 111 | badge.animation = BadgeAnimations.rolling 112 | ~~~ 113 | 114 | ###### Custom 115 | You can also provide your own animation of type ((UIView) -> Void). 116 | 117 | ~~~swift 118 | badge.animation = { badgeView in 119 | ... 120 | } 121 | ~~~ 122 | 123 | #### Initialization 124 | You can use this initalizer with default values: 125 | 126 | ~~~swift 127 | public init(for view: UIView, 128 | in centerPosition: BadgeCenterPosition = .upperRightCorner, 129 | badgeBackgroundColor: UIColor = .red, 130 | badgeTextColor: UIColor = .white, 131 | badgeTextFont: UIFont? = nil, 132 | borderWidth: CGFloat = 0.0, 133 | borderColor: UIColor = .black, 134 | animation: ((UIView) -> Void)? = BadgeAnimations.defaultAnimation, 135 | badgeHeight: Int? = nil 136 | animateOnlyWhenBadgeIsNotYetPresent: Bool = false) 137 | ~~~ 138 | 139 | ## License 140 | 141 | BadgeControl is released under the [MIT License](LICENSE). 142 | 143 | ## Feedback is welcome 144 | 145 | If you've found a bug or want to improve BadgeControl feel free to create an issue. 146 | -------------------------------------------------------------------------------- /RepositoryImages/all.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/all.gif -------------------------------------------------------------------------------- /RepositoryImages/boom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/boom.gif -------------------------------------------------------------------------------- /RepositoryImages/default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/default.gif -------------------------------------------------------------------------------- /RepositoryImages/fadeIn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/fadeIn.gif -------------------------------------------------------------------------------- /RepositoryImages/leftRight.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/leftRight.gif -------------------------------------------------------------------------------- /RepositoryImages/rightLeft.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/rightLeft.gif -------------------------------------------------------------------------------- /RepositoryImages/roll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/roll.gif -------------------------------------------------------------------------------- /RepositoryImages/upperLeftCorner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkrenecky/BadgeControl/fb97545c49732e1a71cff2c16d30eba5b46d5835/RepositoryImages/upperLeftCorner.gif --------------------------------------------------------------------------------