├── LICENSE ├── OGCircularBar-Demo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── OGCircularBar.podspec ├── OGCircularBar.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ └── OGCircularBar.xcscheme └── xcuserdata │ └── oskar.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── OGCircularBar-Demo.xcscheme │ └── xcschememanagement.plist ├── OGCircularBar ├── Info.plist ├── NSBezierPath+CGPath.swift ├── OGCircularBar.h └── OGCircularBarView.swift ├── README.md └── screenshot.jpg /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Oskar Groth 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /OGCircularBar-Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // OGCircularBar-Demo 4 | // 5 | // Created by Oskar Groth on 2017-04-17. 6 | // Copyright © 2017 Oskar Groth. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate, NSURLConnectionDelegate { 13 | 14 | var data = NSMutableData() 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | 19 | } 20 | 21 | 22 | func applicationWillTerminate(_ aNotification: Notification) { 23 | // Insert code here to tear down your application 24 | } 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /OGCircularBar-Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /OGCircularBar-Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 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 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | Default 511 | 512 | 513 | 514 | 515 | 516 | 517 | Left to Right 518 | 519 | 520 | 521 | 522 | 523 | 524 | Right to Left 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | Default 536 | 537 | 538 | 539 | 540 | 541 | 542 | Left to Right 543 | 544 | 545 | 546 | 547 | 548 | 549 | Right to Left 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | -------------------------------------------------------------------------------- /OGCircularBar-Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2017 Oskar Groth. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /OGCircularBar-Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // OGCircularBar-Demo 4 | // 5 | // Created by Oskar Groth on 2017-04-17. 6 | // Copyright © 2017 Oskar Groth. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | @IBOutlet var barView: OGCircularBarView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | let pink = NSColor(calibratedRed: 1, green: 0.059, blue: 0.575, alpha: 1) 18 | let blue = NSColor(calibratedRed: 20/255, green: 160/255, blue: 255, alpha: 1) 19 | let green = NSColor(calibratedRed: 0.321, green: 0.95, blue: 0.2, alpha: 1) 20 | 21 | // Normal Backgrounds 22 | 23 | barView.addBarBackground(startAngle: 90, endAngle: -270, radius: 100, width: 15, color: pink.withAlphaComponent(0.1)) 24 | barView.addBarBackground(startAngle: 90, endAngle: -270, radius: 120, width: 15, color: blue.withAlphaComponent(0.1)) 25 | barView.addBarBackground(startAngle: 90, endAngle: -270, radius: 80, width: 10, color: green.withAlphaComponent(0.1)) 26 | 27 | // Normal Bars 28 | 29 | barView.addBar(startAngle: 90, endAngle: -270, progress: 0 , radius: 100, width: 15, color: pink, animationDuration: 0, glowOpacity: 0.4, glowRadius: 8) 30 | barView.addBar(startAngle: 90, endAngle: -270, progress: 0.45, radius: 120, width: 15, color: blue, animationDuration: 1.5, glowOpacity: 0.4, glowRadius: 8) 31 | barView.addBar(startAngle: 90, endAngle: -270, progress: 0.65, radius: 80, width: 10, color: green, animationDuration: 1.5, glowOpacity: 0.4, glowRadius: 8) 32 | 33 | // Half Bar Backgrounds 34 | 35 | barView.addBarBackground(startAngle: 175, endAngle: 5, radius: 150, width: 15, color: NSColor.magenta.withAlphaComponent(0.1)) 36 | barView.addBarBackground(startAngle: -175, endAngle: -5, radius: 150, width: 15, color: NSColor.cyan.withAlphaComponent(0.1)) 37 | 38 | // Half Bars 39 | 40 | barView.addBar(startAngle: 175, endAngle: 5, progress: 0.50, radius: 150, width: 15, color: NSColor.magenta.withAlphaComponent(0.6), animationDuration: 1.5, glowOpacity: 0.4, glowRadius: 8) 41 | barView.addBar(startAngle: -175, endAngle: -5, progress: 0.50, radius: 150, width: 15, color: NSColor.cyan.withAlphaComponent(0.6), animationDuration: 1.5, glowOpacity: 0.4, glowRadius: 8) 42 | 43 | } 44 | 45 | @IBAction func sliderPress(_ sender: Any) { 46 | let val = CGFloat((sender as! NSSlider).floatValue/100) 47 | barView.bars[0].animateProgress(val, duration: 1.5) 48 | barView.bars.last?.animateProgress(val, duration: 1) 49 | barView.bars[barView.bars.count-2].animateProgress(val, duration: 1) 50 | 51 | } 52 | 53 | override var representedObject: Any? { 54 | didSet { 55 | // Update the view, if already loaded. 56 | } 57 | } 58 | 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /OGCircularBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = 'OGCircularBar' 4 | s.version = '1.2' 5 | s.summary = 'Circular progress bar for macOS' 6 | s.homepage = 'https://github.com/OskarGroth/OGCircularBar' 7 | s.license = { 8 | :type => 'MIT', 9 | :file => 'LICENSE' 10 | } 11 | s.author = { 12 | 'Oskar Groth' => 'oskar@cindori.org' 13 | } 14 | s.source = { 15 | :git => 'https://github.com/OskarGroth/OGCircularBar.git', 16 | :tag => s.version.to_s 17 | } 18 | s.platform = :osx, '10.9' 19 | s.source_files = 'OGCircularBar/*.{swift}' 20 | s.requires_arc = true 21 | s.screenshot = "https://s3.amazonaws.com/cindori/images/circularbar.png" 22 | s.social_media_url = "https://twitter.com/cindoriapps" 23 | 24 | end 25 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 753A29261EA4B26A00B8CC61 /* OGCircularBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 753A29241EA4B26A00B8CC61 /* OGCircularBar.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 753A292E1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A292C1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift */; }; 12 | 753A292F1EA4B29D00B8CC61 /* OGCircularBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A292D1EA4B29D00B8CC61 /* OGCircularBarView.swift */; }; 13 | 753A29371EA4B2BA00B8CC61 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A29361EA4B2BA00B8CC61 /* AppDelegate.swift */; }; 14 | 753A29391EA4B2BA00B8CC61 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A29381EA4B2BA00B8CC61 /* ViewController.swift */; }; 15 | 753A293B1EA4B2BA00B8CC61 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 753A293A1EA4B2BA00B8CC61 /* Assets.xcassets */; }; 16 | 753A293E1EA4B2BA00B8CC61 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 753A293C1EA4B2BA00B8CC61 /* Main.storyboard */; }; 17 | 753A29431EA4B64E00B8CC61 /* NSBezierPath+CGPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A292C1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift */; }; 18 | 753A29441EA4B64E00B8CC61 /* OGCircularBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A292D1EA4B29D00B8CC61 /* OGCircularBarView.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 753A29211EA4B26A00B8CC61 /* OGCircularBar.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OGCircularBar.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 753A29241EA4B26A00B8CC61 /* OGCircularBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OGCircularBar.h; sourceTree = ""; }; 24 | 753A29251EA4B26A00B8CC61 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | 753A292C1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSBezierPath+CGPath.swift"; sourceTree = ""; }; 26 | 753A292D1EA4B29D00B8CC61 /* OGCircularBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OGCircularBarView.swift; sourceTree = ""; }; 27 | 753A29341EA4B2BA00B8CC61 /* OGCircularBar-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OGCircularBar-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 753A29361EA4B2BA00B8CC61 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 29 | 753A29381EA4B2BA00B8CC61 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 30 | 753A293A1EA4B2BA00B8CC61 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | 753A293D1EA4B2BA00B8CC61 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 32 | 753A293F1EA4B2BA00B8CC61 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 753A291D1EA4B26A00B8CC61 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | 753A29311EA4B2BA00B8CC61 /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXFrameworksBuildPhase section */ 51 | 52 | /* Begin PBXGroup section */ 53 | 753A29171EA4B26A00B8CC61 = { 54 | isa = PBXGroup; 55 | children = ( 56 | 753A29231EA4B26A00B8CC61 /* OGCircularBar */, 57 | 753A29351EA4B2BA00B8CC61 /* OGCircularBar-Demo */, 58 | 753A29221EA4B26A00B8CC61 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 753A29221EA4B26A00B8CC61 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 753A29211EA4B26A00B8CC61 /* OGCircularBar.framework */, 66 | 753A29341EA4B2BA00B8CC61 /* OGCircularBar-Demo.app */, 67 | ); 68 | name = Products; 69 | sourceTree = ""; 70 | }; 71 | 753A29231EA4B26A00B8CC61 /* OGCircularBar */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 753A292C1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift */, 75 | 753A292D1EA4B29D00B8CC61 /* OGCircularBarView.swift */, 76 | 753A29241EA4B26A00B8CC61 /* OGCircularBar.h */, 77 | 753A29251EA4B26A00B8CC61 /* Info.plist */, 78 | ); 79 | path = OGCircularBar; 80 | sourceTree = ""; 81 | }; 82 | 753A29351EA4B2BA00B8CC61 /* OGCircularBar-Demo */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 753A29381EA4B2BA00B8CC61 /* ViewController.swift */, 86 | 753A29361EA4B2BA00B8CC61 /* AppDelegate.swift */, 87 | 753A293A1EA4B2BA00B8CC61 /* Assets.xcassets */, 88 | 753A293C1EA4B2BA00B8CC61 /* Main.storyboard */, 89 | 753A293F1EA4B2BA00B8CC61 /* Info.plist */, 90 | ); 91 | path = "OGCircularBar-Demo"; 92 | sourceTree = ""; 93 | }; 94 | /* End PBXGroup section */ 95 | 96 | /* Begin PBXHeadersBuildPhase section */ 97 | 753A291E1EA4B26A00B8CC61 /* Headers */ = { 98 | isa = PBXHeadersBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | 753A29261EA4B26A00B8CC61 /* OGCircularBar.h in Headers */, 102 | ); 103 | runOnlyForDeploymentPostprocessing = 0; 104 | }; 105 | /* End PBXHeadersBuildPhase section */ 106 | 107 | /* Begin PBXNativeTarget section */ 108 | 753A29201EA4B26A00B8CC61 /* OGCircularBar */ = { 109 | isa = PBXNativeTarget; 110 | buildConfigurationList = 753A29291EA4B26A00B8CC61 /* Build configuration list for PBXNativeTarget "OGCircularBar" */; 111 | buildPhases = ( 112 | 753A291C1EA4B26A00B8CC61 /* Sources */, 113 | 753A291D1EA4B26A00B8CC61 /* Frameworks */, 114 | 753A291E1EA4B26A00B8CC61 /* Headers */, 115 | 753A291F1EA4B26A00B8CC61 /* Resources */, 116 | ); 117 | buildRules = ( 118 | ); 119 | dependencies = ( 120 | ); 121 | name = OGCircularBar; 122 | productName = OGCircularBar; 123 | productReference = 753A29211EA4B26A00B8CC61 /* OGCircularBar.framework */; 124 | productType = "com.apple.product-type.framework"; 125 | }; 126 | 753A29331EA4B2BA00B8CC61 /* OGCircularBar-Demo */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 753A29401EA4B2BA00B8CC61 /* Build configuration list for PBXNativeTarget "OGCircularBar-Demo" */; 129 | buildPhases = ( 130 | 753A29301EA4B2BA00B8CC61 /* Sources */, 131 | 753A29311EA4B2BA00B8CC61 /* Frameworks */, 132 | 753A29321EA4B2BA00B8CC61 /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | ); 138 | name = "OGCircularBar-Demo"; 139 | productName = "OGCircularBar-Demo"; 140 | productReference = 753A29341EA4B2BA00B8CC61 /* OGCircularBar-Demo.app */; 141 | productType = "com.apple.product-type.application"; 142 | }; 143 | /* End PBXNativeTarget section */ 144 | 145 | /* Begin PBXProject section */ 146 | 753A29181EA4B26A00B8CC61 /* Project object */ = { 147 | isa = PBXProject; 148 | attributes = { 149 | LastSwiftUpdateCheck = 0830; 150 | LastUpgradeCheck = 0830; 151 | ORGANIZATIONNAME = "Oskar Groth"; 152 | TargetAttributes = { 153 | 753A29201EA4B26A00B8CC61 = { 154 | CreatedOnToolsVersion = 8.3; 155 | DevelopmentTeam = ZQK6SX26CE; 156 | LastSwiftMigration = 0830; 157 | ProvisioningStyle = Automatic; 158 | }; 159 | 753A29331EA4B2BA00B8CC61 = { 160 | CreatedOnToolsVersion = 8.3; 161 | DevelopmentTeam = ZQK6SX26CE; 162 | LastSwiftMigration = 0910; 163 | ProvisioningStyle = Automatic; 164 | }; 165 | }; 166 | }; 167 | buildConfigurationList = 753A291B1EA4B26A00B8CC61 /* Build configuration list for PBXProject "OGCircularBar" */; 168 | compatibilityVersion = "Xcode 3.2"; 169 | developmentRegion = English; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | Base, 174 | ); 175 | mainGroup = 753A29171EA4B26A00B8CC61; 176 | productRefGroup = 753A29221EA4B26A00B8CC61 /* Products */; 177 | projectDirPath = ""; 178 | projectRoot = ""; 179 | targets = ( 180 | 753A29201EA4B26A00B8CC61 /* OGCircularBar */, 181 | 753A29331EA4B2BA00B8CC61 /* OGCircularBar-Demo */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | 753A291F1EA4B26A00B8CC61 /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | ); 192 | runOnlyForDeploymentPostprocessing = 0; 193 | }; 194 | 753A29321EA4B2BA00B8CC61 /* Resources */ = { 195 | isa = PBXResourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | 753A293B1EA4B2BA00B8CC61 /* Assets.xcassets in Resources */, 199 | 753A293E1EA4B2BA00B8CC61 /* Main.storyboard in Resources */, 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | /* End PBXResourcesBuildPhase section */ 204 | 205 | /* Begin PBXSourcesBuildPhase section */ 206 | 753A291C1EA4B26A00B8CC61 /* Sources */ = { 207 | isa = PBXSourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | 753A292E1EA4B29D00B8CC61 /* NSBezierPath+CGPath.swift in Sources */, 211 | 753A292F1EA4B29D00B8CC61 /* OGCircularBarView.swift in Sources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | 753A29301EA4B2BA00B8CC61 /* Sources */ = { 216 | isa = PBXSourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | 753A29431EA4B64E00B8CC61 /* NSBezierPath+CGPath.swift in Sources */, 220 | 753A29441EA4B64E00B8CC61 /* OGCircularBarView.swift in Sources */, 221 | 753A29391EA4B2BA00B8CC61 /* ViewController.swift in Sources */, 222 | 753A29371EA4B2BA00B8CC61 /* AppDelegate.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | /* End PBXSourcesBuildPhase section */ 227 | 228 | /* Begin PBXVariantGroup section */ 229 | 753A293C1EA4B2BA00B8CC61 /* Main.storyboard */ = { 230 | isa = PBXVariantGroup; 231 | children = ( 232 | 753A293D1EA4B2BA00B8CC61 /* Base */, 233 | ); 234 | name = Main.storyboard; 235 | sourceTree = ""; 236 | }; 237 | /* End PBXVariantGroup section */ 238 | 239 | /* Begin XCBuildConfiguration section */ 240 | 753A29271EA4B26A00B8CC61 /* Debug */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_ANALYZER_NONNULL = YES; 245 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 246 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 247 | CLANG_CXX_LIBRARY = "libc++"; 248 | CLANG_ENABLE_MODULES = YES; 249 | CLANG_ENABLE_OBJC_ARC = YES; 250 | CLANG_WARN_BOOL_CONVERSION = YES; 251 | CLANG_WARN_CONSTANT_CONVERSION = YES; 252 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 253 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 254 | CLANG_WARN_EMPTY_BODY = YES; 255 | CLANG_WARN_ENUM_CONVERSION = YES; 256 | CLANG_WARN_INFINITE_RECURSION = YES; 257 | CLANG_WARN_INT_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | CODE_SIGN_IDENTITY = "-"; 263 | COPY_PHASE_STRIP = NO; 264 | CURRENT_PROJECT_VERSION = 1; 265 | DEBUG_INFORMATION_FORMAT = dwarf; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | ENABLE_TESTABILITY = YES; 268 | GCC_C_LANGUAGE_STANDARD = gnu99; 269 | GCC_DYNAMIC_NO_PIC = NO; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_OPTIMIZATION_LEVEL = 0; 272 | GCC_PREPROCESSOR_DEFINITIONS = ( 273 | "DEBUG=1", 274 | "$(inherited)", 275 | ); 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | MACOSX_DEPLOYMENT_TARGET = 10.12; 283 | MTL_ENABLE_DEBUG_INFO = YES; 284 | ONLY_ACTIVE_ARCH = YES; 285 | SDKROOT = macosx; 286 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 288 | VERSIONING_SYSTEM = "apple-generic"; 289 | VERSION_INFO_PREFIX = ""; 290 | }; 291 | name = Debug; 292 | }; 293 | 753A29281EA4B26A00B8CC61 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ALWAYS_SEARCH_USER_PATHS = NO; 297 | CLANG_ANALYZER_NONNULL = YES; 298 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_MODULES = YES; 302 | CLANG_ENABLE_OBJC_ARC = YES; 303 | CLANG_WARN_BOOL_CONVERSION = YES; 304 | CLANG_WARN_CONSTANT_CONVERSION = YES; 305 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 306 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INFINITE_RECURSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 312 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | CODE_SIGN_IDENTITY = "-"; 316 | COPY_PHASE_STRIP = NO; 317 | CURRENT_PROJECT_VERSION = 1; 318 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 319 | ENABLE_NS_ASSERTIONS = NO; 320 | ENABLE_STRICT_OBJC_MSGSEND = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_NO_COMMON_BLOCKS = YES; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | MACOSX_DEPLOYMENT_TARGET = 10.12; 330 | MTL_ENABLE_DEBUG_INFO = NO; 331 | SDKROOT = macosx; 332 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 333 | VERSIONING_SYSTEM = "apple-generic"; 334 | VERSION_INFO_PREFIX = ""; 335 | }; 336 | name = Release; 337 | }; 338 | 753A292A1EA4B26A00B8CC61 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | CLANG_ENABLE_MODULES = YES; 342 | CODE_SIGN_IDENTITY = ""; 343 | COMBINE_HIDPI_IMAGES = YES; 344 | DEFINES_MODULE = YES; 345 | DEVELOPMENT_TEAM = ZQK6SX26CE; 346 | DYLIB_COMPATIBILITY_VERSION = 1; 347 | DYLIB_CURRENT_VERSION = 1; 348 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 349 | FRAMEWORK_VERSION = A; 350 | INFOPLIST_FILE = OGCircularBar/Info.plist; 351 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 352 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 353 | MACOSX_DEPLOYMENT_TARGET = 10.9; 354 | PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGCircularBar; 355 | PRODUCT_NAME = "$(TARGET_NAME)"; 356 | SKIP_INSTALL = YES; 357 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 358 | SWIFT_VERSION = 4.2; 359 | }; 360 | name = Debug; 361 | }; 362 | 753A292B1EA4B26A00B8CC61 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | CLANG_ENABLE_MODULES = YES; 366 | CODE_SIGN_IDENTITY = ""; 367 | COMBINE_HIDPI_IMAGES = YES; 368 | DEFINES_MODULE = YES; 369 | DEVELOPMENT_TEAM = ZQK6SX26CE; 370 | DYLIB_COMPATIBILITY_VERSION = 1; 371 | DYLIB_CURRENT_VERSION = 1; 372 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 373 | FRAMEWORK_VERSION = A; 374 | INFOPLIST_FILE = OGCircularBar/Info.plist; 375 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 377 | MACOSX_DEPLOYMENT_TARGET = 10.9; 378 | PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGCircularBar; 379 | PRODUCT_NAME = "$(TARGET_NAME)"; 380 | SKIP_INSTALL = YES; 381 | SWIFT_VERSION = 4.2; 382 | }; 383 | name = Release; 384 | }; 385 | 753A29411EA4B2BA00B8CC61 /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 389 | COMBINE_HIDPI_IMAGES = YES; 390 | DEVELOPMENT_TEAM = ZQK6SX26CE; 391 | INFOPLIST_FILE = "OGCircularBar-Demo/Info.plist"; 392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 393 | PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.OGCircularBar-Demo"; 394 | PRODUCT_NAME = "$(TARGET_NAME)"; 395 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 396 | SWIFT_VERSION = 4.2; 397 | }; 398 | name = Debug; 399 | }; 400 | 753A29421EA4B2BA00B8CC61 /* Release */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 404 | COMBINE_HIDPI_IMAGES = YES; 405 | DEVELOPMENT_TEAM = ZQK6SX26CE; 406 | INFOPLIST_FILE = "OGCircularBar-Demo/Info.plist"; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 408 | PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.OGCircularBar-Demo"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 411 | SWIFT_VERSION = 4.2; 412 | }; 413 | name = Release; 414 | }; 415 | /* End XCBuildConfiguration section */ 416 | 417 | /* Begin XCConfigurationList section */ 418 | 753A291B1EA4B26A00B8CC61 /* Build configuration list for PBXProject "OGCircularBar" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | 753A29271EA4B26A00B8CC61 /* Debug */, 422 | 753A29281EA4B26A00B8CC61 /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | defaultConfigurationName = Release; 426 | }; 427 | 753A29291EA4B26A00B8CC61 /* Build configuration list for PBXNativeTarget "OGCircularBar" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 753A292A1EA4B26A00B8CC61 /* Debug */, 431 | 753A292B1EA4B26A00B8CC61 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 753A29401EA4B2BA00B8CC61 /* Build configuration list for PBXNativeTarget "OGCircularBar-Demo" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 753A29411EA4B2BA00B8CC61 /* Debug */, 440 | 753A29421EA4B2BA00B8CC61 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 753A29181EA4B26A00B8CC61 /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/xcshareddata/xcschemes/OGCircularBar.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/xcuserdata/oskar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/xcuserdata/oskar.xcuserdatad/xcschemes/OGCircularBar-Demo.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 | -------------------------------------------------------------------------------- /OGCircularBar.xcodeproj/xcuserdata/oskar.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OGCircularBar-Demo.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | OGCircularBar.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 753A29201EA4B26A00B8CC61 21 | 22 | primary 23 | 24 | 25 | 753A29331EA4B2BA00B8CC61 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /OGCircularBar/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSHumanReadableCopyright 22 | Copyright © 2017 Oskar Groth. All rights reserved. 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /OGCircularBar/NSBezierPath+CGPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSBezierPath+CGPath.swift 3 | // OGCircularBar 4 | // 5 | // Created by Oskar Groth on 2017-04-15. 6 | // Copyright © 2017 Oskar Groth. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AppKit 11 | 12 | extension NSBezierPath { 13 | 14 | internal var cgPath: CGPath { 15 | let path = CGMutablePath() 16 | var points = [CGPoint](repeating: .zero, count: 3) 17 | for i in 0 ..< self.elementCount { 18 | let type = self.element(at: i, associatedPoints: &points) 19 | switch type { 20 | case .moveTo: path.move(to: points[0]) 21 | case .lineTo: path.addLine(to: points[0]) 22 | case .curveTo: path.addCurve(to: points[2], control1: points[0], control2: points[1]) 23 | case .closePath: path.closeSubpath() 24 | } 25 | } 26 | return path 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /OGCircularBar/OGCircularBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // OGCircularBar.h 3 | // OGCircularBar 4 | // 5 | // Created by Oskar Groth on 2017-04-17. 6 | // Copyright © 2017 Oskar Groth. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for OGCircularBar. 12 | FOUNDATION_EXPORT double OGCircularBarVersionNumber; 13 | 14 | //! Project version string for OGCircularBar. 15 | FOUNDATION_EXPORT const unsigned char OGCircularBarVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /OGCircularBar/OGCircularBarView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OGCircularBar.swift 3 | // OGCircularBar 4 | // 5 | // Created by Oskar Groth on 2017-02-19. 6 | // Copyright © 2017 Oskar Groth. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | public class OGCircularBarView: NSView, Sequence { 12 | 13 | public var bars: [CircularBarLayer] = [] 14 | public var circleBars: [CircularBarLayer] = [] 15 | var center: CGPoint { 16 | get { 17 | return NSMakePoint(floor(bounds.width/2), floor(bounds.height/2)) 18 | } 19 | } 20 | 21 | public override func awakeFromNib() { 22 | super.awakeFromNib() 23 | setup() 24 | } 25 | 26 | override public init(frame frameRect: NSRect) { 27 | super.init(frame: frameRect) 28 | setup() 29 | } 30 | 31 | required public init?(coder aDecoder: NSCoder) { 32 | super.init(coder: aDecoder) 33 | setup() 34 | } 35 | 36 | func setup() { 37 | wantsLayer = true 38 | } 39 | 40 | public func addBar(startAngle: CGFloat, endAngle: CGFloat, progress: CGFloat, radius: CGFloat, width: CGFloat, color: NSColor, animationDuration: CGFloat, glowOpacity: Float, glowRadius: CGFloat) { 41 | let barLayer = CircularBarLayer(center: center, radius: radius, width: width, startAngle: startAngle, endAngle: endAngle, color: color) 42 | barLayer.shadowColor = color.cgColor 43 | barLayer.shadowRadius = glowRadius 44 | barLayer.shadowOpacity = glowOpacity 45 | barLayer.shadowOffset = NSSize.zero 46 | 47 | layer?.addSublayer(barLayer) 48 | bars.append(barLayer) 49 | if animationDuration > 0 { 50 | barLayer.animateProgress(progress, duration: animationDuration) 51 | } else { 52 | barLayer.progress = progress 53 | } 54 | } 55 | 56 | public func addBarBackground(startAngle: CGFloat, endAngle: CGFloat, radius: CGFloat, width: CGFloat, color: NSColor) { 57 | let barLayer = CircularBarLayer(center: center, radius: radius, width: width, startAngle: startAngle, endAngle: endAngle, color: color) 58 | barLayer.progress = 1 59 | layer?.addSublayer(barLayer) 60 | } 61 | 62 | 63 | public subscript(index: Int) -> CircularBarLayer { 64 | return bars[index] 65 | } 66 | 67 | public func makeIterator() -> IndexingIterator<[CircularBarLayer]> { 68 | return bars.makeIterator() 69 | } 70 | 71 | } 72 | 73 | open class CircularBarLayer: CAShapeLayer, CALayerDelegate, CAAnimationDelegate { 74 | 75 | var completion: (() -> Void)? 76 | 77 | open var progress: CGFloat? { 78 | get { 79 | return strokeEnd 80 | } 81 | set { 82 | strokeEnd = (newValue ?? 0) 83 | } 84 | } 85 | 86 | public init(center: CGPoint, radius: CGFloat, width: CGFloat, startAngle: CGFloat, endAngle: CGFloat, color: NSColor) { 87 | super.init() 88 | let bezier = NSBezierPath() 89 | bezier.appendArc(withCenter: NSZeroPoint, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: startAngle > endAngle) 90 | bezier.transform(using: AffineTransform(translationByX: center.x, byY: center.y)) 91 | delegate = self as CALayerDelegate 92 | path = bezier.cgPath 93 | fillColor = NSColor.clear.cgColor 94 | strokeColor = color.cgColor 95 | lineWidth = width 96 | lineCap = CAShapeLayerLineCap.round 97 | strokeStart = 0 98 | strokeEnd = 0 99 | } 100 | 101 | public required init?(coder aDecoder: NSCoder) { 102 | super.init(coder: aDecoder) 103 | } 104 | 105 | override init(layer: Any) { 106 | super.init(layer: layer) 107 | } 108 | 109 | open func animateProgress(_ progress: CGFloat, duration: CGFloat, completion: (() -> Void)? = nil) { 110 | removeAllAnimations() 111 | let progress = progress 112 | let animation = CABasicAnimation(keyPath: "strokeEnd") 113 | animation.fromValue = strokeEnd 114 | animation.toValue = progress 115 | animation.duration = CFTimeInterval(duration) 116 | animation.delegate = self as CAAnimationDelegate 117 | animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) 118 | strokeEnd = progress 119 | add(animation, forKey: "strokeEnd") 120 | } 121 | 122 | public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { 123 | if flag { 124 | completion?() 125 | } 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OGCircularBar 2 | ================== 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | 5 | Circular progress bar for macOS. 6 | 7 | This is a NSView subclass that lets you create beautiful circular progress bars. 8 | Multiple bars can be added in one view, and styling options such as size, color and glow are available. Animatable. 9 | 10 | ![OGCircularBar for macOS](https://s3.amazonaws.com/cindori/images/circularbar.png "OGCircularBar for macOS") 11 | 12 | ## Installation (CocoaPods) 13 | Configure your Podfile to use `OGCircularBar`: 14 | 15 | ```pod 'OGCircularBar'``` 16 | 17 | ## Usage 18 | 19 | Create an `OGCircularBarView` and add bars as such: 20 | 21 | `barView.addBar(startAngle: 90, endAngle: -270, progress: 0 , radius: 100, width: 15, color: NSColor.purple, animationDuration: 0, glowOpacity: 0.4, glowRadius: 8)` 22 | 23 | You can add static backgrounds with the following method: 24 | 25 | `barView.addBarBackground(startAngle: 90, endAngle: -270, radius: 80, width: 10, color: NSColor.purple.withAlphaComponent(0.1))` 26 | 27 | Animations are also supported: 28 | 29 | `barView.bars[1].animateProgress(val, duration: 1.5)` 30 |         31 | 32 | ## License 33 | The MIT License (MIT) 34 | 35 | Copyright (c) 2017 Oskar Groth 36 | 37 | Permission is hereby granted, free of charge, to any person obtaining a copy of 38 | this software and associated documentation files (the "Software"), to deal in 39 | the Software without restriction, including without limitation the rights to 40 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 41 | the Software, and to permit persons to whom the Software is furnished to do so, 42 | subject to the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be included in all 45 | copies or substantial portions of the Software. 46 | 47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 48 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 49 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 50 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 51 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 52 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarGroth/OGCircularBar/d2fe2c0cb12ca5cb5571bd9e3b885ad8a2f4ce19/screenshot.jpg --------------------------------------------------------------------------------