Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Commit bd71656

Browse files
author
Luis Padron
committed
Version 1.6.2
- Add new delegate method to UICircularProgressRingDelegate - Update docs to use Apple theme - Reran Jazzy for updated code/docs
1 parent cbc36c8 commit bd71656

38 files changed

+1303
-4994
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Version 1.6.2
2+
3+
#### Highlight: New `UICircularProgressRingDelegate` method.
4+
5+
- New method in `UICircularProgressRingDelegate `, `didUpdateProgressValue(to newValue: CGFloat)`, which can be used to get notified of value changes to the progress ring in real time. As the documentation states, this is a very hot method and it may be called hundreds of times per second, thus only very minimal work should be performed in this method.
6+
17
# Version 1.6.1
28

39
- Make sure `.swift-version` is included in pod, in order to fix issue with Xcode 9

UICircularProgressRing.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "UICircularProgressRing"
5-
s.version = "1.6.1"
5+
s.version = "1.6.2"
66
s.summary = "A highly customizable circular progress bar for iOS written in Swift 3"
77

88
s.description = <<-DESC

UICircularProgressRing/UICircularProgressRingDelegate.swift

+21
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,25 @@ public protocol UICircularProgressRingDelegate: class {
4545

4646
*/
4747
func finishedUpdatingProgress(forRing ring: UICircularProgressRingView)
48+
49+
/**
50+
This method is called whenever the value is updated, this means during animation this method will be called in real time.
51+
This can be used to update another label or do some other work, whenever you need the exact current value of the ring
52+
during animation.
53+
54+
## Important:
55+
56+
This is a very hot method and may be called hundreds of times per second during animations. As such make sure to only
57+
do very simple and non-intensive work in this method. Do any work that takes time will considerably slow down your application.
58+
59+
- Paramater newValue: The value which the ring has updated to
60+
*/
61+
func didUpdateProgressValue(to newValue: CGFloat)
62+
}
63+
64+
65+
/// Protocol extension to add default conformance
66+
public extension UICircularProgressRingDelegate {
67+
// Adds default conformance with an empty method stub
68+
func didUpdateProgressValue(to newValue: CGFloat) { }
4869
}

UICircularProgressRing/UICircularProgressRingLayer.swift

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class UICircularProgressRingLayer: CAShapeLayer {
103103
var animationDuration: TimeInterval = 1.0
104104
var animationStyle: String = kCAMediaTimingFunctionEaseInEaseOut
105105
var animated = false
106+
@NSManaged weak var valueDelegate: UICircularProgressRingView?
106107

107108
// The value label which draws the text for the current value
108109
lazy private var valueLabel: UILabel = UILabel(frame: .zero)
@@ -121,7 +122,12 @@ class UICircularProgressRingLayer: CAShapeLayer {
121122
drawInnerRing(in: ctx)
122123
// Draw the label
123124
drawValueLabel()
125+
// Call the delegate and notifiy of updated value
126+
if let updatedValue = self.value(forKey: "value") as? CGFloat {
127+
valueDelegate?.didUpdateValue(newValue: updatedValue)
128+
}
124129
UIGraphicsPopContext()
130+
125131
}
126132

127133
// MARK: Animation methods

UICircularProgressRing/UICircularProgressRingView.swift

+10
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ import UIKit
703703
This method initializes the custom CALayer to the default values
704704
*/
705705
internal func initialize() {
706+
// This view will become the value delegate of the layer, which will call the updateValue method when needed
707+
self.ringLayer.valueDelegate = self
708+
706709
// Helps with pixelation and blurriness on retina devices
707710
self.layer.contentsScale = UIScreen.main.scale
708711
self.layer.shouldRasterize = true
@@ -753,6 +756,13 @@ import UIKit
753756
super.draw(rect)
754757
}
755758

759+
/**
760+
Called whenever the layer updates its `value` keypath, this method will then simply call its delegate with
761+
the `newValue` so that it notifies any delegates who may need to know about value updates in real time
762+
*/
763+
internal func didUpdateValue(newValue: CGFloat) {
764+
delegate?.didUpdateProgressValue(to: newValue)
765+
}
756766

757767
/**
758768
Typealias for the setProgress(:) method closure

docs/Classes.html

+33-60
Original file line numberDiff line numberDiff line change
@@ -4,100 +4,74 @@
44
<title>Classes Reference</title>
55
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
66
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
7-
<meta charset="utf-8">
7+
<meta charset='utf-8'>
88
<script src="js/jquery.min.js" defer></script>
99
<script src="js/jazzy.js" defer></script>
1010

11-
<script src="js/lunr.min.js" defer></script>
12-
<script src="js/typeahead.jquery.js" defer></script>
13-
<script src="js/jazzy.search.js" defer></script>
1411
</head>
1512
<body>
16-
17-
1813
<a title="Classes Reference"></a>
19-
20-
<header class="header">
21-
<p class="header-col header-col--primary">
22-
<a class="header-link" href="index.html">
23-
UICircularProgressRing Docs
24-
</a>
25-
(100% documented)
26-
</p>
27-
28-
<p class="header-col--secondary">
29-
<form role="search" action="search.json">
30-
<input type="text" placeholder="Search documentation" data-typeahead>
31-
</form>
32-
</p>
33-
34-
<p class="header-col header-col--secondary">
35-
<a class="header-link" href="https://github.com/luispadron/UICircularProgressRing">
36-
<img class="header-icon" src="img/gh.png"/>
37-
View on GitHub
38-
</a>
39-
</p>
40-
14+
<header>
15+
<div class="content-wrapper">
16+
<p><a href="index.html">UICircularProgressRing Docs</a> (100% documented)</p>
17+
<p class="header-right"><a href="https://github.com/luispadron/UICircularProgressRing"><img src="img/gh.png"/>View on GitHub</a></p>
18+
</div>
4119
</header>
42-
43-
<p class="breadcrumbs">
44-
<a class="breadcrumb" href="index.html">UICircularProgressRing Reference</a>
45-
<img class="carat" src="img/carat.png" />
46-
Classes Reference
47-
</p>
48-
4920
<div class="content-wrapper">
50-
<nav class="navigation">
21+
<p id="breadcrumbs">
22+
<a href="index.html">UICircularProgressRing Reference</a>
23+
<img id="carat" src="img/carat.png" />
24+
Classes Reference
25+
</p>
26+
</div>
27+
<div class="content-wrapper">
28+
<nav class="sidebar">
5129
<ul class="nav-groups">
5230
<li class="nav-group-name">
53-
<a class="nav-group-name-link" href="Classes.html">Classes</a>
31+
<a href="Classes.html">Classes</a>
5432
<ul class="nav-group-tasks">
5533
<li class="nav-group-task">
56-
<a class="nav-group-task-link" href="Classes/UICircularProgressRingView.html">UICircularProgressRingView</a>
34+
<a href="Classes/UICircularProgressRingView.html">UICircularProgressRingView</a>
5735
</li>
5836
</ul>
5937
</li>
6038
<li class="nav-group-name">
61-
<a class="nav-group-name-link" href="Enums.html">Enums</a>
39+
<a href="Enums.html">Enums</a>
6240
<ul class="nav-group-tasks">
6341
<li class="nav-group-task">
64-
<a class="nav-group-task-link" href="Enums/UICircularProgressRingGradientPosition.html">UICircularProgressRingGradientPosition</a>
42+
<a href="Enums/UICircularProgressRingGradientPosition.html">UICircularProgressRingGradientPosition</a>
6543
</li>
6644
<li class="nav-group-task">
67-
<a class="nav-group-task-link" href="Enums/UICircularProgressRingStyle.html">UICircularProgressRingStyle</a>
45+
<a href="Enums/UICircularProgressRingStyle.html">UICircularProgressRingStyle</a>
6846
</li>
6947
</ul>
7048
</li>
7149
<li class="nav-group-name">
72-
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
50+
<a href="Protocols.html">Protocols</a>
7351
<ul class="nav-group-tasks">
7452
<li class="nav-group-task">
75-
<a class="nav-group-task-link" href="Protocols/UICircularProgressRingDelegate.html">UICircularProgressRingDelegate</a>
53+
<a href="Protocols/UICircularProgressRingDelegate.html">UICircularProgressRingDelegate</a>
7654
</li>
7755
</ul>
7856
</li>
7957
</ul>
8058
</nav>
8159
<article class="main-content">
82-
83-
<section class="section">
84-
<div class="section-content">
60+
<section>
61+
<section class="section">
8562
<h1>Classes</h1>
8663
<p>The following classes are available globally.</p>
8764

88-
</div>
89-
</section>
90-
91-
<section class="section">
92-
<div class="section-content">
65+
</section>
66+
<section class="section task-group-section">
9367
<div class="task-group">
94-
<ul class="item-container">
68+
<ul>
9569
<li class="item">
9670
<div>
9771
<code>
98-
<a name="/s:C22UICircularProgressRing26UICircularProgressRingView"></a>
72+
<a name="/c:@M@UICircularProgressRing@objc(cs)UICircularProgressRingView"></a>
9973
<a name="//apple_ref/swift/Class/UICircularProgressRingView" class="dashAnchor"></a>
100-
<a class="token" href="#/s:C22UICircularProgressRing26UICircularProgressRingView">UICircularProgressRingView</a>
74+
<a class="token" href="#/c:@M@UICircularProgressRing@objc(cs)UICircularProgressRingView">UICircularProgressRingView</a>
10175
</code>
10276
</div>
10377
<div class="height-container">
@@ -137,15 +111,14 @@ <h4>Declaration</h4>
137111
</li>
138112
</ul>
139113
</div>
140-
</div>
114+
</section>
115+
</section>
116+
<section id="footer">
117+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-07-03)</p>
118+
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
141119
</section>
142-
143120
</article>
144121
</div>
145-
<section class="footer">
146-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-06-06)</p>
147-
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
148-
</section>
149122
</body>
150123
</div>
151124
</html>

0 commit comments

Comments
 (0)