├── .gitignore ├── CircleProgressBar.podspec ├── CircleProgressBarDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── CircleProgressBarDemo ├── AppDelegate │ ├── AppDelegate.h │ └── AppDelegate.m ├── Base.lproj │ └── Main.storyboard ├── CircleProgressBar │ ├── CircleProgressBar.h │ └── CircleProgressBar.m ├── Controllers │ ├── DemoViewController.h │ └── DemoViewController.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-29@2x.png │ │ ├── Icon-29@3x.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ └── Icon-60@3x.png │ └── LaunchImage.launchimage │ │ ├── Contents.json │ │ ├── LaunchImage-5@2x.png │ │ ├── LaunchImage-5small@2x.png │ │ ├── LaunchImage-6@2x.png │ │ └── LaunchImage-6plus@3x.png ├── Info.plist └── main.m ├── CircleProgressBarDemoTests ├── CircleProgressBarDemoTests.m └── Info.plist ├── LICENSE ├── README.md └── Screenshots ├── ios-screen01.png ├── ios-screen02.png └── xcode-screen01.png /.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 | -------------------------------------------------------------------------------- /CircleProgressBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CircleProgressBar" 3 | s.version = "0.32" 4 | s.summary = "Circle ProgressBar control for iOS." 5 | s.description = <<-DESC 6 | Provides wide range of customization options. 7 | Supports XCode 6 live rendering feature for on-the-fly customization. 8 | Has ability to animate ProgressBar's progress chage. 9 | DESC 10 | s.homepage = "https://github.com/Eclair/CircleProgressBar" 11 | s.screenshots = "https://raw.githubusercontent.com/Eclair/CircleProgressBar/master/Screenshots/ios-screen01.png", "https://raw.githubusercontent.com/Eclair/CircleProgressBar/master/Screenshots/ios-screen02.png" 12 | s.license = 'MIT' 13 | s.author = { "Andrey Cherkashin" => "cherkashin.andrey90@gmail.com" } 14 | s.source = { :git => "https://github.com/Eclair/CircleProgressBar.git", :tag => s.version.to_s } 15 | s.platforms = { :ios => '7.0', :tvos => "9.0" } 16 | s.requires_arc = true 17 | s.source_files = 'CircleProgressBarDemo/CircleProgressBar/*' 18 | s.framework = 'UIKit', 'QuartzCore' 19 | end 20 | -------------------------------------------------------------------------------- /CircleProgressBarDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BA2831831AB88E2400497BFD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BA2831821AB88E2400497BFD /* main.m */; }; 11 | BA28318C1AB88E2400497BFD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA28318A1AB88E2400497BFD /* Main.storyboard */; }; 12 | BA28318E1AB88E2400497BFD /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA28318D1AB88E2400497BFD /* Images.xcassets */; }; 13 | BA28319D1AB88E2400497BFD /* CircleProgressBarDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA28319C1AB88E2400497BFD /* CircleProgressBarDemoTests.m */; }; 14 | BA2831AF1AB88E9500497BFD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BA2831A81AB88E9500497BFD /* AppDelegate.m */; }; 15 | BA2831B01AB88E9500497BFD /* CircleProgressBar.m in Sources */ = {isa = PBXBuildFile; fileRef = BA2831AB1AB88E9500497BFD /* CircleProgressBar.m */; }; 16 | BA2831B11AB88E9500497BFD /* DemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BA2831AE1AB88E9500497BFD /* DemoViewController.m */; }; 17 | BA2831B31AB88EC600497BFD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA2831B21AB88EC600497BFD /* QuartzCore.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | BA2831971AB88E2400497BFD /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = BA2831751AB88E2400497BFD /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = BA28317C1AB88E2400497BFD; 26 | remoteInfo = CircleProgressBarDemo; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | BA28317D1AB88E2400497BFD /* CircleProgressBarDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CircleProgressBarDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | BA2831811AB88E2400497BFD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | BA2831821AB88E2400497BFD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | BA28318B1AB88E2400497BFD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | BA28318D1AB88E2400497BFD /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 36 | BA2831961AB88E2400497BFD /* CircleProgressBarDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CircleProgressBarDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | BA28319B1AB88E2400497BFD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | BA28319C1AB88E2400497BFD /* CircleProgressBarDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CircleProgressBarDemoTests.m; sourceTree = ""; }; 39 | BA2831A71AB88E9500497BFD /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | BA2831A81AB88E9500497BFD /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | BA2831AA1AB88E9500497BFD /* CircleProgressBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleProgressBar.h; sourceTree = ""; }; 42 | BA2831AB1AB88E9500497BFD /* CircleProgressBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CircleProgressBar.m; sourceTree = ""; }; 43 | BA2831AD1AB88E9500497BFD /* DemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoViewController.h; sourceTree = ""; }; 44 | BA2831AE1AB88E9500497BFD /* DemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoViewController.m; sourceTree = ""; }; 45 | BA2831B21AB88EC600497BFD /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | BA28317A1AB88E2400497BFD /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | BA2831B31AB88EC600497BFD /* QuartzCore.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | BA2831931AB88E2400497BFD /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | BA2831741AB88E2400497BFD = { 68 | isa = PBXGroup; 69 | children = ( 70 | BA28317F1AB88E2400497BFD /* CircleProgressBarDemo */, 71 | BA2831991AB88E2400497BFD /* CircleProgressBarDemoTests */, 72 | BA28317E1AB88E2400497BFD /* Products */, 73 | BA2831B41AB8905100497BFD /* Frameworks */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | BA28317E1AB88E2400497BFD /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | BA28317D1AB88E2400497BFD /* CircleProgressBarDemo.app */, 81 | BA2831961AB88E2400497BFD /* CircleProgressBarDemoTests.xctest */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | BA28317F1AB88E2400497BFD /* CircleProgressBarDemo */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | BA2831A61AB88E9500497BFD /* AppDelegate */, 90 | BA2831A91AB88E9500497BFD /* CircleProgressBar */, 91 | BA2831AC1AB88E9500497BFD /* Controllers */, 92 | BA28318A1AB88E2400497BFD /* Main.storyboard */, 93 | BA28318D1AB88E2400497BFD /* Images.xcassets */, 94 | BA2831801AB88E2400497BFD /* Supporting Files */, 95 | ); 96 | path = CircleProgressBarDemo; 97 | sourceTree = ""; 98 | }; 99 | BA2831801AB88E2400497BFD /* Supporting Files */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | BA2831811AB88E2400497BFD /* Info.plist */, 103 | BA2831821AB88E2400497BFD /* main.m */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | BA2831991AB88E2400497BFD /* CircleProgressBarDemoTests */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | BA28319C1AB88E2400497BFD /* CircleProgressBarDemoTests.m */, 112 | BA28319A1AB88E2400497BFD /* Supporting Files */, 113 | ); 114 | path = CircleProgressBarDemoTests; 115 | sourceTree = ""; 116 | }; 117 | BA28319A1AB88E2400497BFD /* Supporting Files */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | BA28319B1AB88E2400497BFD /* Info.plist */, 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | BA2831A61AB88E9500497BFD /* AppDelegate */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | BA2831A71AB88E9500497BFD /* AppDelegate.h */, 129 | BA2831A81AB88E9500497BFD /* AppDelegate.m */, 130 | ); 131 | path = AppDelegate; 132 | sourceTree = ""; 133 | }; 134 | BA2831A91AB88E9500497BFD /* CircleProgressBar */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | BA2831AA1AB88E9500497BFD /* CircleProgressBar.h */, 138 | BA2831AB1AB88E9500497BFD /* CircleProgressBar.m */, 139 | ); 140 | path = CircleProgressBar; 141 | sourceTree = ""; 142 | }; 143 | BA2831AC1AB88E9500497BFD /* Controllers */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | BA2831AD1AB88E9500497BFD /* DemoViewController.h */, 147 | BA2831AE1AB88E9500497BFD /* DemoViewController.m */, 148 | ); 149 | path = Controllers; 150 | sourceTree = ""; 151 | }; 152 | BA2831B41AB8905100497BFD /* Frameworks */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | BA2831B21AB88EC600497BFD /* QuartzCore.framework */, 156 | ); 157 | name = Frameworks; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | BA28317C1AB88E2400497BFD /* CircleProgressBarDemo */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = BA2831A01AB88E2400497BFD /* Build configuration list for PBXNativeTarget "CircleProgressBarDemo" */; 166 | buildPhases = ( 167 | BA2831791AB88E2400497BFD /* Sources */, 168 | BA28317A1AB88E2400497BFD /* Frameworks */, 169 | BA28317B1AB88E2400497BFD /* Resources */, 170 | ); 171 | buildRules = ( 172 | ); 173 | dependencies = ( 174 | ); 175 | name = CircleProgressBarDemo; 176 | productName = CircleProgressBarDemo; 177 | productReference = BA28317D1AB88E2400497BFD /* CircleProgressBarDemo.app */; 178 | productType = "com.apple.product-type.application"; 179 | }; 180 | BA2831951AB88E2400497BFD /* CircleProgressBarDemoTests */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = BA2831A31AB88E2400497BFD /* Build configuration list for PBXNativeTarget "CircleProgressBarDemoTests" */; 183 | buildPhases = ( 184 | BA2831921AB88E2400497BFD /* Sources */, 185 | BA2831931AB88E2400497BFD /* Frameworks */, 186 | BA2831941AB88E2400497BFD /* Resources */, 187 | ); 188 | buildRules = ( 189 | ); 190 | dependencies = ( 191 | BA2831981AB88E2400497BFD /* PBXTargetDependency */, 192 | ); 193 | name = CircleProgressBarDemoTests; 194 | productName = CircleProgressBarDemoTests; 195 | productReference = BA2831961AB88E2400497BFD /* CircleProgressBarDemoTests.xctest */; 196 | productType = "com.apple.product-type.bundle.unit-test"; 197 | }; 198 | /* End PBXNativeTarget section */ 199 | 200 | /* Begin PBXProject section */ 201 | BA2831751AB88E2400497BFD /* Project object */ = { 202 | isa = PBXProject; 203 | attributes = { 204 | LastUpgradeCheck = 0720; 205 | ORGANIZATIONNAME = Eclair; 206 | TargetAttributes = { 207 | BA28317C1AB88E2400497BFD = { 208 | CreatedOnToolsVersion = 6.2; 209 | }; 210 | BA2831951AB88E2400497BFD = { 211 | CreatedOnToolsVersion = 6.2; 212 | TestTargetID = BA28317C1AB88E2400497BFD; 213 | }; 214 | }; 215 | }; 216 | buildConfigurationList = BA2831781AB88E2400497BFD /* Build configuration list for PBXProject "CircleProgressBarDemo" */; 217 | compatibilityVersion = "Xcode 3.2"; 218 | developmentRegion = English; 219 | hasScannedForEncodings = 0; 220 | knownRegions = ( 221 | en, 222 | Base, 223 | ); 224 | mainGroup = BA2831741AB88E2400497BFD; 225 | productRefGroup = BA28317E1AB88E2400497BFD /* Products */; 226 | projectDirPath = ""; 227 | projectRoot = ""; 228 | targets = ( 229 | BA28317C1AB88E2400497BFD /* CircleProgressBarDemo */, 230 | BA2831951AB88E2400497BFD /* CircleProgressBarDemoTests */, 231 | ); 232 | }; 233 | /* End PBXProject section */ 234 | 235 | /* Begin PBXResourcesBuildPhase section */ 236 | BA28317B1AB88E2400497BFD /* Resources */ = { 237 | isa = PBXResourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | BA28318C1AB88E2400497BFD /* Main.storyboard in Resources */, 241 | BA28318E1AB88E2400497BFD /* Images.xcassets in Resources */, 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | BA2831941AB88E2400497BFD /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | ); 250 | runOnlyForDeploymentPostprocessing = 0; 251 | }; 252 | /* End PBXResourcesBuildPhase section */ 253 | 254 | /* Begin PBXSourcesBuildPhase section */ 255 | BA2831791AB88E2400497BFD /* Sources */ = { 256 | isa = PBXSourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | BA2831AF1AB88E9500497BFD /* AppDelegate.m in Sources */, 260 | BA2831831AB88E2400497BFD /* main.m in Sources */, 261 | BA2831B01AB88E9500497BFD /* CircleProgressBar.m in Sources */, 262 | BA2831B11AB88E9500497BFD /* DemoViewController.m in Sources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | BA2831921AB88E2400497BFD /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | BA28319D1AB88E2400497BFD /* CircleProgressBarDemoTests.m in Sources */, 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | }; 274 | /* End PBXSourcesBuildPhase section */ 275 | 276 | /* Begin PBXTargetDependency section */ 277 | BA2831981AB88E2400497BFD /* PBXTargetDependency */ = { 278 | isa = PBXTargetDependency; 279 | target = BA28317C1AB88E2400497BFD /* CircleProgressBarDemo */; 280 | targetProxy = BA2831971AB88E2400497BFD /* PBXContainerItemProxy */; 281 | }; 282 | /* End PBXTargetDependency section */ 283 | 284 | /* Begin PBXVariantGroup section */ 285 | BA28318A1AB88E2400497BFD /* Main.storyboard */ = { 286 | isa = PBXVariantGroup; 287 | children = ( 288 | BA28318B1AB88E2400497BFD /* Base */, 289 | ); 290 | name = Main.storyboard; 291 | sourceTree = ""; 292 | }; 293 | /* End PBXVariantGroup section */ 294 | 295 | /* Begin XCBuildConfiguration section */ 296 | BA28319E1AB88E2400497BFD /* Debug */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ALWAYS_SEARCH_USER_PATHS = NO; 300 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 301 | CLANG_CXX_LIBRARY = "libc++"; 302 | CLANG_ENABLE_MODULES = YES; 303 | CLANG_ENABLE_OBJC_ARC = YES; 304 | CLANG_WARN_BOOL_CONVERSION = YES; 305 | CLANG_WARN_CONSTANT_CONVERSION = YES; 306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INT_CONVERSION = YES; 310 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 311 | CLANG_WARN_UNREACHABLE_CODE = YES; 312 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 313 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 314 | COPY_PHASE_STRIP = NO; 315 | ENABLE_STRICT_OBJC_MSGSEND = YES; 316 | ENABLE_TESTABILITY = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_DYNAMIC_NO_PIC = NO; 319 | GCC_OPTIMIZATION_LEVEL = 0; 320 | GCC_PREPROCESSOR_DEFINITIONS = ( 321 | "DEBUG=1", 322 | "$(inherited)", 323 | ); 324 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 332 | MTL_ENABLE_DEBUG_INFO = YES; 333 | ONLY_ACTIVE_ARCH = YES; 334 | SDKROOT = iphoneos; 335 | }; 336 | name = Debug; 337 | }; 338 | BA28319F1AB88E2400497BFD /* Release */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ALWAYS_SEARCH_USER_PATHS = NO; 342 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 343 | CLANG_CXX_LIBRARY = "libc++"; 344 | CLANG_ENABLE_MODULES = YES; 345 | CLANG_ENABLE_OBJC_ARC = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_CONSTANT_CONVERSION = YES; 348 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 349 | CLANG_WARN_EMPTY_BODY = YES; 350 | CLANG_WARN_ENUM_CONVERSION = YES; 351 | CLANG_WARN_INT_CONVERSION = YES; 352 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 353 | CLANG_WARN_UNREACHABLE_CODE = YES; 354 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 355 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 356 | COPY_PHASE_STRIP = NO; 357 | ENABLE_NS_ASSERTIONS = NO; 358 | ENABLE_STRICT_OBJC_MSGSEND = YES; 359 | GCC_C_LANGUAGE_STANDARD = gnu99; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | BA2831A11AB88E2400497BFD /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 378 | INFOPLIST_FILE = CircleProgressBarDemo/Info.plist; 379 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 381 | PRODUCT_BUNDLE_IDENTIFIER = "com.eclair.$(PRODUCT_NAME:rfc1034identifier)"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | }; 384 | name = Debug; 385 | }; 386 | BA2831A21AB88E2400497BFD /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 390 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 391 | INFOPLIST_FILE = CircleProgressBarDemo/Info.plist; 392 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 393 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 394 | PRODUCT_BUNDLE_IDENTIFIER = "com.eclair.$(PRODUCT_NAME:rfc1034identifier)"; 395 | PRODUCT_NAME = "$(TARGET_NAME)"; 396 | }; 397 | name = Release; 398 | }; 399 | BA2831A41AB88E2400497BFD /* Debug */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | BUNDLE_LOADER = "$(TEST_HOST)"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(SDKROOT)/Developer/Library/Frameworks", 405 | "$(inherited)", 406 | ); 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | INFOPLIST_FILE = CircleProgressBarDemoTests/Info.plist; 412 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 413 | PRODUCT_BUNDLE_IDENTIFIER = "com.eclair.$(PRODUCT_NAME:rfc1034identifier)"; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CircleProgressBarDemo.app/CircleProgressBarDemo"; 416 | }; 417 | name = Debug; 418 | }; 419 | BA2831A51AB88E2400497BFD /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | BUNDLE_LOADER = "$(TEST_HOST)"; 423 | FRAMEWORK_SEARCH_PATHS = ( 424 | "$(SDKROOT)/Developer/Library/Frameworks", 425 | "$(inherited)", 426 | ); 427 | INFOPLIST_FILE = CircleProgressBarDemoTests/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 429 | PRODUCT_BUNDLE_IDENTIFIER = "com.eclair.$(PRODUCT_NAME:rfc1034identifier)"; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CircleProgressBarDemo.app/CircleProgressBarDemo"; 432 | }; 433 | name = Release; 434 | }; 435 | /* End XCBuildConfiguration section */ 436 | 437 | /* Begin XCConfigurationList section */ 438 | BA2831781AB88E2400497BFD /* Build configuration list for PBXProject "CircleProgressBarDemo" */ = { 439 | isa = XCConfigurationList; 440 | buildConfigurations = ( 441 | BA28319E1AB88E2400497BFD /* Debug */, 442 | BA28319F1AB88E2400497BFD /* Release */, 443 | ); 444 | defaultConfigurationIsVisible = 0; 445 | defaultConfigurationName = Release; 446 | }; 447 | BA2831A01AB88E2400497BFD /* Build configuration list for PBXNativeTarget "CircleProgressBarDemo" */ = { 448 | isa = XCConfigurationList; 449 | buildConfigurations = ( 450 | BA2831A11AB88E2400497BFD /* Debug */, 451 | BA2831A21AB88E2400497BFD /* Release */, 452 | ); 453 | defaultConfigurationIsVisible = 0; 454 | defaultConfigurationName = Release; 455 | }; 456 | BA2831A31AB88E2400497BFD /* Build configuration list for PBXNativeTarget "CircleProgressBarDemoTests" */ = { 457 | isa = XCConfigurationList; 458 | buildConfigurations = ( 459 | BA2831A41AB88E2400497BFD /* Debug */, 460 | BA2831A51AB88E2400497BFD /* Release */, 461 | ); 462 | defaultConfigurationIsVisible = 0; 463 | defaultConfigurationName = Release; 464 | }; 465 | /* End XCConfigurationList section */ 466 | }; 467 | rootObject = BA2831751AB88E2400497BFD /* Project object */; 468 | } 469 | -------------------------------------------------------------------------------- /CircleProgressBarDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/AppDelegate/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CircleProgressBarDemo 4 | // 5 | // Created by Andrew Cherkashin on 3/17/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/AppDelegate/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CircleProgressBarDemo 4 | // 5 | // Created by Andrew Cherkashin on 3/17/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 51 | 66 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 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 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/CircleProgressBar/CircleProgressBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // CircleProgressBar.h 3 | // CircleProgressBar 4 | // 5 | // Created by Andrew Cherkashin on 3/16/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NSString*(^StringGenerationBlock)(CGFloat progress); 12 | typedef NSAttributedString*(^AttributedStringGenerationBlock)(CGFloat progress); 13 | 14 | /** Class that represents CircleProgressBar itself. 15 | 16 | CircleProgressBar can be initialized programmatically or using InterfaceBuilder. 17 | 18 | To change progress in CircleProgressBar just use: 19 | 20 | [ setProgress:(CGFloat) animated:(BOOL)animated]; 21 | 22 | Interface provides ability to customize each element of CircleProgressBar independently; 23 | 24 | */ 25 | IB_DESIGNABLE 26 | @interface CircleProgressBar : UIView 27 | 28 | /// @brief Width of Progress Bar 29 | @property (nonatomic) IBInspectable CGFloat progressBarWidth; 30 | /// @brief Progress color in Progress Bar 31 | @property (nonatomic) IBInspectable UIColor *progressBarProgressColor; 32 | /// @brief Track color in Progress Bar 33 | @property (nonatomic) IBInspectable UIColor *progressBarTrackColor; 34 | /// @brief Start Angle 35 | @property (nonatomic) IBInspectable CGFloat startAngle; 36 | 37 | /// @brief Whether HintView should be shown or not 38 | @property (nonatomic) IBInspectable BOOL hintHidden; 39 | /// @brief Inner spacing between Progress Bar and Hint View 40 | @property (nonatomic) IBInspectable CGFloat hintViewSpacing; 41 | /// @brief Hint View Background Color 42 | @property (nonatomic) IBInspectable UIColor *hintViewBackgroundColor; 43 | /// @brief Hint View Text Font 44 | @property (nonatomic) IBInspectable UIFont *hintTextFont; 45 | /// @brief Hint View Text Color 46 | @property (nonatomic) IBInspectable UIColor *hintTextColor; 47 | 48 | /** Used to set block that generates NSString according to progress, to show it in Hint View 49 | 50 | @param StringGenerationBlock block with CGFloat progress parameter, that returns NSString* 51 | */ 52 | - (void)setHintTextGenerationBlock:(StringGenerationBlock)generationBlock; 53 | 54 | /** Used to set block that generates NSAttributedString according to progress, to show it in Hint View 55 | 56 | @param AttributedStringGenerationBlock block with CGFloat progress parameter, that returns NSAttributedString* 57 | */ 58 | - (void)setHintAttributedGenerationBlock:(AttributedStringGenerationBlock)generationBlock; 59 | 60 | /// @brief Current ProgressBar's progress (Read-Only) 61 | /// To change ProgressBar's progress use setProgress:animated: 62 | @property (nonatomic, readonly) IBInspectable CGFloat progress; 63 | 64 | /// @brief Indicates of there is ongoing animation 65 | @property (nonatomic, readonly) BOOL isAnimating; 66 | 67 | /** Used to set progress with animation or without 68 | 69 | @param progress progress to be set 70 | @param animated should control animate progress change or not 71 | */ 72 | - (void)setProgress:(CGFloat)progress animated:(BOOL)animated; 73 | 74 | /** Used to set progress with animation and custom duration 75 | 76 | @param progress progress to be set 77 | @param animated should control animate progress change or not 78 | @param duration animation duration (default is 0.2f) 79 | */ 80 | - (void)setProgress:(CGFloat)progress animated:(BOOL)animated duration:(CGFloat)duration; 81 | 82 | /// Used to stop ongoing animation 83 | - (void)stopAnimation; 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/CircleProgressBar/CircleProgressBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // CircleProgressBar.m 3 | // CircleProgressBar 4 | // 5 | // Created by Andrew Cherkashin on 3/16/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import "CircleProgressBar.h" 10 | 11 | // Common 12 | #define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI) 13 | 14 | // Progress Bar Defaults 15 | #define DefaultProgressBarProgressColor [UIColor colorWithRed:0.71 green:0.099 blue:0.099 alpha:0.7] 16 | #define DefaultProgressBarTrackColor [UIColor colorWithRed:1 green:1 blue:1 alpha:0.7] 17 | const CGFloat DefaultProgressBarWidth = 33.0f; 18 | 19 | // Hint View Defaults 20 | #define DefaultHintBackgroundColor [UIColor colorWithWhite:0 alpha:0.7] 21 | #define DefaultHintTextFont [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:30.0f] 22 | #define DefaultHintTextColor [UIColor whiteColor] 23 | const CGFloat DefaultHintSpacing = 20.0f; 24 | const StringGenerationBlock DefaultHintTextGenerationBlock = ^NSString *(CGFloat progress) { 25 | return [NSString stringWithFormat:@"%.0f%%", progress * 100]; 26 | }; 27 | 28 | // Animation Constants 29 | const CGFloat AnimationChangeTimeDuration = 0.2f; 30 | const CGFloat AnimationChangeTimeStep = 0.01f; 31 | 32 | @interface CircleProgressBar (Private) 33 | 34 | // Common 35 | - (CGFloat)progressAccordingToBounds:(CGFloat)progress; 36 | 37 | // Base Drawing 38 | - (void)drawBackground:(CGContextRef)context; 39 | 40 | // ProgressBar Drawing 41 | - (UIColor*)progressBarProgressColorForDrawing; 42 | - (UIColor*)progressBarTrackColorForDrawing; 43 | - (CGFloat)progressBarWidthForDrawing; 44 | - (void)drawProgressBar:(CGContextRef)context progressAngle:(CGFloat)progressAngle center:(CGPoint)center radius:(CGFloat)radius; 45 | 46 | // Hint Drawing 47 | - (CGFloat)hintViewSpacingForDrawing; 48 | - (UIColor*)hintViewBackgroundColorForDrawing; 49 | - (UIFont*)hintTextFontForDrawing; 50 | - (UIColor*)hintTextColorForDrawing; 51 | - (NSString*)stringRepresentationOfProgress:(CGFloat)progress; 52 | - (void)drawSimpleHintTextAtCenter:(CGPoint)center; 53 | - (void)drawAttributedHintTextAtCenter:(CGPoint)center; 54 | - (void)drawHint:(CGContextRef)context center:(CGPoint)center radius:(CGFloat)radius; 55 | 56 | // Animation 57 | - (void)animateProgressBarChangeFrom:(CGFloat)startProgress to:(CGFloat)endProgress duration:(CGFloat)duration; 58 | - (void)updateProgressBarForAnimation; 59 | 60 | @end 61 | 62 | @implementation CircleProgressBar { 63 | NSTimer *_animationTimer; 64 | CGFloat _currentAnimationProgress, _startProgress, _endProgress, _animationProgressStep; 65 | StringGenerationBlock _hintTextGenerationBlock; 66 | AttributedStringGenerationBlock _hintAttributedTextGenerationBlock; 67 | } 68 | 69 | - (BOOL)isAnimating { 70 | return _animationTimer != nil; 71 | } 72 | 73 | - (void)setProgress:(CGFloat)progress animated:(BOOL)animated { 74 | [self setProgress:progress animated:animated duration:AnimationChangeTimeDuration]; 75 | } 76 | 77 | - (void)setProgress:(CGFloat)progress animated:(BOOL)animated duration:(CGFloat)duration; { 78 | progress = [self progressAccordingToBounds:progress]; 79 | if (_progress == progress) { 80 | return; 81 | } 82 | 83 | [_animationTimer invalidate]; 84 | _animationTimer = nil; 85 | 86 | if (animated) { 87 | [self animateProgressBarChangeFrom:_progress to:progress duration:duration]; 88 | } else { 89 | _progress = progress; 90 | [self setNeedsDisplay]; 91 | } 92 | } 93 | 94 | - (void)stopAnimation { 95 | if (!self.isAnimating) { 96 | return; 97 | } 98 | 99 | [_animationTimer invalidate]; 100 | _animationTimer = nil; 101 | _progress = _endProgress; 102 | [self setNeedsDisplay]; 103 | } 104 | 105 | - (void)drawRect:(CGRect)rect { 106 | [super drawRect:rect]; 107 | 108 | CGPoint innerCenter = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); 109 | CGFloat radius = MIN(innerCenter.x, innerCenter.y); 110 | CGFloat currentProgressAngle = (_progress * 360) + _startAngle; 111 | 112 | CGContextRef context = UIGraphicsGetCurrentContext(); 113 | CGContextClearRect(context, rect); 114 | 115 | [self drawBackground:context]; 116 | 117 | [self drawProgressBar:context progressAngle:currentProgressAngle center:innerCenter radius:radius]; 118 | if (!_hintHidden) { 119 | [self drawHint:context center:innerCenter radius:radius]; 120 | } 121 | } 122 | 123 | #pragma mark - Setters with View Update 124 | 125 | - (void)setProgressBarWidth:(CGFloat)progressBarWidth { 126 | _progressBarWidth = progressBarWidth; 127 | [self setNeedsDisplay]; 128 | } 129 | 130 | - (void)setProgressBarProgressColor:(UIColor *)progressBarProgressColor { 131 | _progressBarProgressColor = progressBarProgressColor; 132 | [self setNeedsDisplay]; 133 | } 134 | 135 | - (void)setProgressBarTrackColor:(UIColor *)progressBarTrackColor { 136 | _progressBarTrackColor = progressBarTrackColor; 137 | [self setNeedsDisplay]; 138 | } 139 | 140 | - (void)setHintHidden:(BOOL)isHintHidden { 141 | _hintHidden = isHintHidden; 142 | [self setNeedsDisplay]; 143 | } 144 | 145 | - (void)setHintViewSpacing:(CGFloat)hintViewSpacing { 146 | _hintViewSpacing = hintViewSpacing; 147 | [self setNeedsDisplay]; 148 | } 149 | 150 | - (void)setHintViewBackgroundColor:(UIColor *)hintViewBackgroundColor { 151 | _hintViewBackgroundColor = hintViewBackgroundColor; 152 | [self setNeedsDisplay]; 153 | } 154 | 155 | - (void)setHintTextFont:(UIFont *)hintTextFont { 156 | _hintTextFont = hintTextFont; 157 | [self setNeedsDisplay]; 158 | } 159 | 160 | - (void)setHintTextColor:(UIColor *)hintTextColor { 161 | _hintTextColor = hintTextColor; 162 | [self setNeedsDisplay]; 163 | } 164 | 165 | - (void)setHintTextGenerationBlock:(StringGenerationBlock)generationBlock { 166 | _hintTextGenerationBlock = generationBlock; 167 | [self setNeedsDisplay]; 168 | } 169 | 170 | - (void)setHintAttributedGenerationBlock:(AttributedStringGenerationBlock)generationBlock { 171 | _hintAttributedTextGenerationBlock = generationBlock; 172 | [self setNeedsDisplay]; 173 | } 174 | 175 | - (void)setStartAngle:(CGFloat)startAngle { 176 | _startAngle = startAngle; 177 | [self setNeedsDisplay]; 178 | } 179 | 180 | @end 181 | 182 | @implementation CircleProgressBar (Private) 183 | 184 | #pragma mark - Common 185 | 186 | - (CGFloat)progressAccordingToBounds:(CGFloat)progress { 187 | progress = MIN(progress, 1); 188 | progress = MAX(progress, 0); 189 | return progress; 190 | } 191 | 192 | #pragma mark - Base Drawing 193 | 194 | - (void)drawBackground:(CGContextRef)context { 195 | CGContextSetFillColorWithColor(context, self.backgroundColor.CGColor); 196 | CGContextFillRect(context, self.bounds); 197 | } 198 | 199 | #pragma mark - ProgressBar Drawing 200 | 201 | - (UIColor*)progressBarProgressColorForDrawing { 202 | return (_progressBarProgressColor != nil ? _progressBarProgressColor : DefaultProgressBarProgressColor); 203 | } 204 | 205 | - (UIColor*)progressBarTrackColorForDrawing { 206 | return (_progressBarTrackColor != nil ? _progressBarTrackColor : DefaultProgressBarTrackColor); 207 | } 208 | 209 | - (CGFloat)progressBarWidthForDrawing { 210 | return (_progressBarWidth > 0 ? _progressBarWidth : DefaultProgressBarWidth); 211 | } 212 | 213 | - (void)drawProgressBar:(CGContextRef)context progressAngle:(CGFloat)progressAngle center:(CGPoint)center radius:(CGFloat)radius { 214 | CGFloat barWidth = self.progressBarWidthForDrawing; 215 | if (barWidth > radius) { 216 | barWidth = radius; 217 | } 218 | 219 | CGContextSetFillColorWithColor(context, self.progressBarProgressColorForDrawing.CGColor); 220 | CGContextBeginPath(context); 221 | CGContextAddArc(context, center.x, center.y, radius, DEGREES_TO_RADIANS(_startAngle), DEGREES_TO_RADIANS(progressAngle), 0); 222 | CGContextAddArc(context, center.x, center.y, radius - barWidth, DEGREES_TO_RADIANS(progressAngle), DEGREES_TO_RADIANS(_startAngle), 1); 223 | CGContextClosePath(context); 224 | CGContextFillPath(context); 225 | 226 | CGContextSetFillColorWithColor(context, self.progressBarTrackColorForDrawing.CGColor); 227 | CGContextBeginPath(context); 228 | CGContextAddArc(context, center.x, center.y, radius, DEGREES_TO_RADIANS(progressAngle), DEGREES_TO_RADIANS(_startAngle + 360), 0); 229 | CGContextAddArc(context, center.x, center.y, radius - barWidth, DEGREES_TO_RADIANS(_startAngle + 360), DEGREES_TO_RADIANS(progressAngle), 1); 230 | CGContextClosePath(context); 231 | CGContextFillPath(context); 232 | } 233 | 234 | #pragma mark - Hint Drawing 235 | 236 | - (CGFloat)hintViewSpacingForDrawing { 237 | return (_hintViewSpacing != 0 ? _hintViewSpacing : DefaultHintSpacing); 238 | } 239 | 240 | - (UIColor*)hintViewBackgroundColorForDrawing { 241 | return (_hintViewBackgroundColor != nil ? _hintViewBackgroundColor : DefaultHintBackgroundColor); 242 | } 243 | 244 | - (UIFont*)hintTextFontForDrawing { 245 | return (_hintTextFont != nil ? _hintTextFont : DefaultHintTextFont); 246 | } 247 | 248 | - (UIColor*)hintTextColorForDrawing { 249 | return (_hintTextColor != nil ? _hintTextColor : DefaultHintTextColor); 250 | } 251 | 252 | - (NSString*)stringRepresentationOfProgress:(CGFloat)progress { 253 | return (_hintTextGenerationBlock != nil ? _hintTextGenerationBlock(progress) : DefaultHintTextGenerationBlock(progress)); 254 | } 255 | 256 | - (void)drawSimpleHintTextAtCenter:(CGPoint)center { 257 | NSString *progressString = [self stringRepresentationOfProgress:_progress]; 258 | CGSize hintTextSize = [progressString boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName: self.hintTextFontForDrawing} context:nil].size; 259 | [progressString drawAtPoint:CGPointMake(center.x - hintTextSize.width / 2, center.y - hintTextSize.height / 2) withAttributes:@{NSFontAttributeName: self.hintTextFontForDrawing, NSForegroundColorAttributeName: self.hintTextColorForDrawing}]; 260 | } 261 | 262 | - (void)drawAttributedHintTextAtCenter:(CGPoint)center { 263 | NSAttributedString *progressString = _hintAttributedTextGenerationBlock(_progress); 264 | CGSize hintTextSize = [progressString boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesFontLeading context:nil].size; 265 | [progressString drawAtPoint:CGPointMake(center.x - hintTextSize.width / 2, center.y - hintTextSize.height / 2)]; 266 | } 267 | 268 | - (void)drawHint:(CGContextRef)context center:(CGPoint)center radius:(CGFloat)radius { 269 | CGFloat barWidth = self.progressBarWidthForDrawing; 270 | if (barWidth + self.hintViewSpacingForDrawing > radius) { 271 | return; 272 | } 273 | 274 | CGContextSetFillColorWithColor(context, self.hintViewBackgroundColorForDrawing.CGColor); 275 | CGContextBeginPath(context); 276 | CGContextAddArc(context, center.x, center.y, radius - barWidth - self.hintViewSpacingForDrawing, DEGREES_TO_RADIANS(0), DEGREES_TO_RADIANS(360), 1); 277 | CGContextClosePath(context); 278 | CGContextFillPath(context); 279 | 280 | if (_hintAttributedTextGenerationBlock != nil) { 281 | [self drawAttributedHintTextAtCenter:center]; 282 | } else { 283 | [self drawSimpleHintTextAtCenter:center]; 284 | } 285 | } 286 | 287 | #pragma mark - Amination 288 | 289 | - (void)animateProgressBarChangeFrom:(CGFloat)startProgress to:(CGFloat)endProgress duration:(CGFloat)duration { 290 | _currentAnimationProgress = _startProgress = startProgress; 291 | _endProgress = endProgress; 292 | 293 | _animationProgressStep = (_endProgress - _startProgress) * AnimationChangeTimeStep / duration; 294 | 295 | _animationTimer = [NSTimer scheduledTimerWithTimeInterval:AnimationChangeTimeStep target:self selector:@selector(updateProgressBarForAnimation) userInfo:nil repeats:YES]; 296 | [[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:NSRunLoopCommonModes]; 297 | } 298 | 299 | - (void)updateProgressBarForAnimation { 300 | _currentAnimationProgress += _animationProgressStep; 301 | _progress = _currentAnimationProgress; 302 | if ((_animationProgressStep > 0 && _currentAnimationProgress >= _endProgress) || (_animationProgressStep < 0 && _currentAnimationProgress <= _endProgress)) { 303 | [_animationTimer invalidate]; 304 | _animationTimer = nil; 305 | _progress = _endProgress; 306 | } 307 | [self setNeedsDisplay]; 308 | } 309 | 310 | @end -------------------------------------------------------------------------------- /CircleProgressBarDemo/Controllers/DemoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CircleProgressBar 4 | // 5 | // Created by Andrew Cherkashin on 3/15/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class CircleProgressBar; 12 | 13 | typedef enum : NSUInteger { 14 | CustomizationStateDefault = 0, 15 | CustomizationStateCustom, 16 | CustomizationStateCustomAttributed, 17 | } CustomizationState; 18 | 19 | @interface DemoViewController : UIViewController 20 | 21 | @property (weak, nonatomic) IBOutlet CircleProgressBar *circleProgressBar; 22 | @property (weak, nonatomic) IBOutlet UIButton *customizeButton; 23 | 24 | - (IBAction)increaseProgress:(id)sender; 25 | - (IBAction)decreaseProgress:(id)sender; 26 | - (IBAction)customizeNext:(id)sender; 27 | 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/Controllers/DemoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CircleProgressBar 4 | // 5 | // Created by Andrew Cherkashin on 3/15/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import "DemoViewController.h" 10 | #import "CircleProgressBar.h" 11 | 12 | @interface DemoViewController (Private) 13 | 14 | - (CustomizationState)nextCustomizationState:(CustomizationState)state; 15 | - (NSString*)buttonTextForState:(CustomizationState)state; 16 | - (void)customizeAccordingToState:(CustomizationState)state; 17 | 18 | @end 19 | 20 | @implementation DemoViewController { 21 | CustomizationState _state; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | } 27 | 28 | - (IBAction)increaseProgress:(id)sender { 29 | [_circleProgressBar setProgress:(_circleProgressBar.progress + 0.06f) animated:YES]; 30 | } 31 | 32 | - (IBAction)decreaseProgress:(id)sender { 33 | [_circleProgressBar setProgress:(_circleProgressBar.progress - 0.06f) animated:YES]; 34 | } 35 | 36 | - (IBAction)customizeNext:(id)sender { 37 | _state = [self nextCustomizationState:_state]; 38 | 39 | [self customizeAccordingToState:_state]; 40 | 41 | [_customizeButton setTitle:[self buttonTextForState:_state] forState:UIControlStateNormal]; 42 | } 43 | 44 | @end 45 | 46 | @implementation DemoViewController (Private) 47 | 48 | - (CustomizationState)nextCustomizationState:(CustomizationState)state { 49 | switch (state) { 50 | case CustomizationStateCustomAttributed: return 0; 51 | default: return (state + 1); 52 | } 53 | } 54 | 55 | - (NSString*)buttonTextForState:(CustomizationState)state { 56 | switch ([self nextCustomizationState:state]) { 57 | case CustomizationStateDefault: return @"BACK TO DEFAULTS"; 58 | case CustomizationStateCustom: return @"CUSTOMIZE"; 59 | case CustomizationStateCustomAttributed: return @"ADD ATTRIBUTED TEXT"; 60 | } 61 | } 62 | 63 | - (void)customizeAccordingToState:(CustomizationState)state { 64 | BOOL customized = state != CustomizationStateDefault; 65 | 66 | // Progress Bar Customization 67 | [_circleProgressBar setProgressBarWidth:(customized ? 12.0f : 0)]; 68 | [_circleProgressBar setProgressBarProgressColor:(customized ? [UIColor colorWithRed:0.2 green:0.7 blue:1.0 alpha:0.8] : nil)]; 69 | [_circleProgressBar setProgressBarTrackColor:(customized ? [UIColor colorWithWhite:0.000 alpha:0.800] : nil)]; 70 | 71 | // Hint View Customization 72 | [_circleProgressBar setHintViewSpacing:(customized ? 10.0f : 0)]; 73 | [_circleProgressBar setHintViewBackgroundColor:(customized ? [UIColor colorWithWhite:1.000 alpha:0.800] : nil)]; 74 | [_circleProgressBar setHintTextFont:(customized ? [UIFont fontWithName:@"AvenirNextCondensed-Heavy" size:40.0f] : nil)]; 75 | [_circleProgressBar setHintTextColor:(customized ? [UIColor blackColor] : nil)]; 76 | [_circleProgressBar setHintTextGenerationBlock:(customized ? ^NSString *(CGFloat progress) { 77 | return [NSString stringWithFormat:@"%.0f / 255", progress * 255]; 78 | } : nil)]; 79 | 80 | // Attributed String 81 | [_circleProgressBar setHintAttributedGenerationBlock:(state == CustomizationStateCustomAttributed ? ^NSAttributedString *(CGFloat progress) { 82 | NSString *formatString = [NSString stringWithFormat:@"%.0f / 255", progress * 255]; 83 | NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:formatString]; 84 | [string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"AvenirNextCondensed-Heavy" size:40.0f] range:NSMakeRange(0, string.length)]; 85 | 86 | NSArray *components = [formatString componentsSeparatedByString:@"/"]; 87 | UIColor *valueColor = [UIColor colorWithRed:(0.2f) green:(0.2f) blue:(0.5f + progress * 0.5f) alpha:1.0f]; 88 | [string addAttribute:NSForegroundColorAttributeName value:valueColor range:NSMakeRange(0, [[components firstObject] length])]; 89 | [string addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange([[components firstObject] length], 1)]; 90 | [string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange([[components firstObject] length] + 1, [[components lastObject] length])]; 91 | return string; 92 | } : nil)]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-29@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "LaunchImage-6plus@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "667h", 16 | "filename" : "LaunchImage-6@2x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "portrait", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "orientation" : "portrait", 23 | "idiom" : "iphone", 24 | "extent" : "full-screen", 25 | "minimum-system-version" : "7.0", 26 | "filename" : "LaunchImage-5small@2x.png", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "extent" : "full-screen", 31 | "idiom" : "iphone", 32 | "subtype" : "retina4", 33 | "filename" : "LaunchImage-5@2x.png", 34 | "minimum-system-version" : "7.0", 35 | "orientation" : "portrait", 36 | "scale" : "2x" 37 | } 38 | ], 39 | "info" : { 40 | "version" : 1, 41 | "author" : "xcode" 42 | } 43 | } -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-5@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-5small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-5small@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-6@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-6@2x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-6plus@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/CircleProgressBarDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-6plus@3x.png -------------------------------------------------------------------------------- /CircleProgressBarDemo/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 | 0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /CircleProgressBarDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CircleProgressBarDemo 4 | // 5 | // Created by Andrew Cherkashin on 3/17/15. 6 | // Copyright (c) 2015 Eclair. 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 | -------------------------------------------------------------------------------- /CircleProgressBarDemoTests/CircleProgressBarDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CircleProgressBarDemoTests.m 3 | // CircleProgressBarDemoTests 4 | // 5 | // Created by Andrew Cherkashin on 3/17/15. 6 | // Copyright (c) 2015 Eclair. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CircleProgressBarDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation CircleProgressBarDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CircleProgressBarDemoTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Cherkashin Andrey 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CircleProgressBar 2 | ================= 3 | 4 | Circle Progress Bar iOS Control. 5 | 6 | Require iOS 7.0+ or tvOS 9.0+ 7 | 8 | ![CircleProgressBar Screenshot-iOS-Example](https://raw.githubusercontent.com/Eclair/CircleProgressBar/master/Screenshots/ios-screen01.png) 9 | ![CircleProgressBar Screenshot-iOS-Example2](https://raw.githubusercontent.com/Eclair/CircleProgressBar/master/Screenshots/ios-screen02.png) 10 | 11 | Installation 12 | ============ 13 | 14 | You can install this control in two ways: 15 | 16 | 1. Using CocoaPods: 17 | 18 | ```ruby 19 | pod 'CircleProgressBar', '~> 0.32’ 20 | ``` 21 | 22 | 2. Manually: 23 | 24 | Download source from this repository and copy CircleProgressBarDemo/CircleProgressBar folder to your project. 25 | 26 | Don't forget to add **UIKit** and **QuartzCore** frameworks to your project. 27 | 28 | How to use 29 | ========== 30 | 31 | _NOTE: If you installed this control manually - please be sure that you've added UIKit and QuartzCore frameworks to your project._ 32 | 33 | _NOTE: If you're using rectangular view for CircleProgressBar control instead of square, ProgressBar will fit available area and will be drawn in center of it._ 34 | 35 | _NOTE: If you're using swift, be sure to add `import CircleProgressBar` to source file where you're using it._ 36 | 37 | You can simply add UIView in Interface Builder to your controller and change it's class to "CircleProgressBar" (overridden _initWithCoder_ method will be called) or create CircleProgressBar programmatically using _init_ or _initWithFrame_ methods. 38 | 39 | Using Interface Builder you'll take advantage of Xcode 6 new live rendering feature to customize control according to your needs on the fly (will be explained below in "Customization" section). 40 | 41 | To change progress, simply call "setProgress:animated:" method of CircleProgressBar instance: 42 | 43 | **Objective-c**: 44 | ```objective-c 45 | [_circleProgressBar setProgress:(CGFloat)progress animated:(BOOL)animated]; 46 | ``` 47 | **Swift**: 48 | ```swift 49 | circleProgressBar.setProgress(CGFloat, animated: Bool) 50 | ``` 51 | 52 | or "setProgress:animated:duration:" method to define custom animation time: 53 | 54 | 55 | **Objective-c**: 56 | ```objective-c 57 | [_circleProgressBar setProgress:(CGFloat)progress animated:(BOOL)animated duration:(CGFloat)duration]; 58 | ``` 59 | **Swift**: 60 | ```swift 61 | circleProgressBar.setProgress(CGFloat, animated: Bool, duration: CGFloat) 62 | ``` 63 | 64 | To check if there is ongoing animation use `isAnimating` property. 65 | To stop an ongoing animation, you can use `stopAnimation` method. In this case it will set the progress to animation end value: 66 | 67 | **Objective-c**: 68 | ```objective-c 69 | [_circleProgressBar stopAnimation]; 70 | ``` 71 | **Swift**: 72 | ```swift 73 | circleProgressBar.stopAnimation() 74 | ``` 75 | 76 | Customization 77 | ============= 78 | 79 | CircleProgressBar provides many customization properties: 80 | 81 | ```objective-c 82 | // Progress Bar Customization 83 | @property (nonatomic) CGFloat progressBarWidth; 84 | @property (nonatomic) UIColor *progressBarProgressColor; 85 | @property (nonatomic) UIColor *progressBarTrackColor; 86 | @property (nonatomic) CGFloat startAngle; 87 | 88 | // Hint View Customization (inside progress bar) 89 | @property (nonatomic) BOOL hintHidden; 90 | @property (nonatomic) CGFloat hintViewSpacing; 91 | @property (nonatomic) UIColor *hintViewBackgroundColor; 92 | @property (nonatomic) UIFont *hintTextFont; 93 | @property (nonatomic) UIColor *hintTextColor; 94 | ``` 95 | 96 | Using these customization properties you can define Progress Bar's width, color of filled part, color of empty part, Progress Bar's start angle, Hint View's spacing (between progress bar and hint view), background color, hint text color and hint text font. 97 | 98 | If you want to hide HintView you can simply set hintHidden property to NO. 99 | 100 | To customize text inside HintView you can simply set TextGenerationBlock: 101 | 102 | **Objective-c**: 103 | ```objective-c 104 | [_circleProgressBar setHintTextGenerationBlock:(StringGenerationBlock)generationBlock]; 105 | ``` 106 | **Swift**: 107 | ```swift 108 | circleProgressBar.setHintTextGenerationBlock(generationBlock: StringGenerationBlock!) 109 | ``` 110 | 111 | For example this way: 112 | 113 | **Objective-c**: 114 | ```objective-c 115 | [_circleProgressBar setHintTextGenerationBlock:^NSString *(CGFloat progress) { 116 | return [NSString stringWithFormat:@"%.0f / 255", progress * 255]; 117 | }]; 118 | ``` 119 | **Swift**: 120 | ```swift 121 | circleProgressBar.setHintTextGenerationBlock { (progress) -> String? in 122 | return String.init(format: "%.0f / 255", arguments: [progress * 255]) 123 | } 124 | ``` 125 | 126 | If you want to use NSAttributedString you can set instead HintAttributedGenerationBlock: 127 | 128 | **Objective-c**: 129 | ```objective-c 130 | [_circleProgressBar setHintAttributedGenerationBlock:(AttributedStringGenerationBlock)generationBlock]; 131 | ``` 132 | **Swift**: 133 | ```swift 134 | circleProgressBar.setHintAttributedGenerationBlock(generationBlock: AttributedStringGenerationBlock!) 135 | ``` 136 | 137 | If you using Interface Builder, you can take an advantage of Xcode 6 live render with IBDesignable and IBInspectable features to customize control: 138 | 139 | ![CircleProgressBar Screenshot-Xcode-InterfaceBuilder](https://raw.githubusercontent.com/Eclair/CircleProgressBar/master/Screenshots/xcode-screen01.png) 140 | 141 | License (MIT) 142 | ============= 143 | 144 | Copyright (c) 2015-2018 Andrew Cherkashyn 145 | 146 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 147 | 148 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 149 | 150 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 151 | -------------------------------------------------------------------------------- /Screenshots/ios-screen01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/Screenshots/ios-screen01.png -------------------------------------------------------------------------------- /Screenshots/ios-screen02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/Screenshots/ios-screen02.png -------------------------------------------------------------------------------- /Screenshots/xcode-screen01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eclair/CircleProgressBar/16d4bf75e504fe633655b2468831492056d0827c/Screenshots/xcode-screen01.png --------------------------------------------------------------------------------