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

Commit b5d82ac

Browse files
author
Luis Padron
committed
Version 1.4.2
- Add new `fullCircle` property - Update Xcode tests - Update documentation
1 parent e36568c commit b5d82ac

18 files changed

+400
-35
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Version 1.4.2 (latest)
2+
3+
- Add new `fullCircle` property to the `UICircularProgressRingView`. Which removes the confusion of setting a valid end angle. For example previously if you wanted a full circle and you wanted the progress to start from the top you could do `startAngle = -90` however this would also require you to subtract 90 from the end angle, since the default is 360. This was not fully understood by some users. Now you have the option using `fullCircle` to set and forget the `startAngle` and the `endAngle` will automagically be corrected for you, thus always giving you a full circle with your desired start ange.
4+
- Update some Xcode unit tests
5+
- Update documentation to include new `fullCircle` property
6+
7+
#### Breaking changes in 1.4.2
8+
9+
With the addition of the `fullCircle` property which is `true` by default anyone who was using a non-circular progress ring will see that their progress ring is now circular. To fix this either set `fullCircle` to `false` via code or go into interface builder and toggle `Full Circle` to `Off`.
10+
111
# Version 1.4.1
212

313
- Fix bug where the default `valueIndicator` _'%'_ - was not set on initialization

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.4.1"
5+
s.version = "1.4.2"
66
s.summary = "A highly customizable circular progress bar for iOS written in Swift 3"
77

88
s.description = <<-DESC

UICircularProgressRing/UICircularProgressRingLayer.swift

+19-9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class UICircularProgressRingLayer: CAShapeLayer {
6363
These properties are initialized in UICircularProgressRingView.
6464
They're also assigned by mutating UICircularProgressRingView.
6565
*/
66+
@NSManaged var fullCircle: Bool
67+
6668
@NSManaged var value: CGFloat
6769
@NSManaged var maxValue: CGFloat
6870

@@ -154,11 +156,13 @@ class UICircularProgressRingLayer: CAShapeLayer {
154156
let height = bounds.width
155157
let center = CGPoint(x: bounds.midX, y: bounds.midY)
156158
let outerRadius = max(width, height)/2 - outerRingWidth/2
159+
let start = fullCircle ? 0 : startAngle.toRads
160+
let end = fullCircle ? CGFloat.pi*2 : endAngle.toRads
157161

158162
let outerPath = UIBezierPath(arcCenter: center,
159163
radius: outerRadius,
160-
startAngle: startAngle.toRads,
161-
endAngle: endAngle.toRads,
164+
startAngle: start,
165+
endAngle: end,
162166
clockwise: true)
163167

164168
outerPath.lineWidth = outerRingWidth
@@ -185,12 +189,18 @@ class UICircularProgressRingLayer: CAShapeLayer {
185189

186190
let center = CGPoint(x: bounds.midX, y: bounds.midY)
187191

188-
// Calculate the center difference between the end and start angle
189-
let angleDiff: CGFloat = endAngle.toRads - startAngle.toRads
190-
// Calculate how much we should draw depending on the value set
191-
let arcLenPerValue = angleDiff / CGFloat(maxValue)
192-
// The inner end angle some basic math is done
193-
let innerEndAngle = arcLenPerValue * CGFloat(value) + startAngle.toRads
192+
var innerEndAngle: CGFloat = 0.0
193+
194+
if fullCircle {
195+
innerEndAngle = (360.0 / CGFloat(maxValue)) * CGFloat(value) + startAngle
196+
} else {
197+
// Calculate the center difference between the end and start angle
198+
let angleDiff: CGFloat = endAngle - startAngle
199+
// Calculate how much we should draw depending on the value set
200+
let arcLenPerValue = angleDiff / CGFloat(maxValue)
201+
// The inner end angle some basic math is done
202+
innerEndAngle = arcLenPerValue * CGFloat(value) + startAngle
203+
}
194204

195205
// The radius for style 1 is set below
196206
// The radius for style 1 is a bit less than the outer, this way it looks like its inside the circle
@@ -204,7 +214,7 @@ class UICircularProgressRingLayer: CAShapeLayer {
204214
let innerPath = UIBezierPath(arcCenter: center,
205215
radius: radiusIn,
206216
startAngle: startAngle.toRads,
207-
endAngle: innerEndAngle,
217+
endAngle: innerEndAngle.toRads,
208218
clockwise: true)
209219
innerPath.lineWidth = innerRingWidth
210220
innerPath.lineCapStyle = innerCapStyle

UICircularProgressRing/UICircularProgressRingView.swift

+23
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ import UIKit
5858
*/
5959
open weak var delegate: UICircularProgressRingDelegate?
6060

61+
// MARK: Circle Properties
62+
63+
/**
64+
Whether or not the progress ring should be a full circle.
65+
66+
What this means is that the outer ring will always go from 0 - 360 degrees and the inner ring will be calculated accordingly depending on current value.
67+
68+
## Important ##
69+
Default = true
70+
71+
When this property is true any value set for `endAngle` will be ignored.
72+
73+
## Author:
74+
Luis Padron
75+
76+
*/
77+
@IBInspectable open var fullCircle: Bool = true {
78+
didSet {
79+
self.ringLayer.fullCircle = self.fullCircle
80+
}
81+
}
82+
6183
// MARK: Value Properties
6284

6385
/**
@@ -556,6 +578,7 @@ import UIKit
556578
self.layer.contentsScale = UIScreen.main.scale
557579
self.layer.shouldRasterize = true
558580
self.layer.rasterizationScale = UIScreen.main.scale * 2
581+
self.ringLayer.fullCircle = fullCircle
559582
self.ringLayer.value = value
560583
self.ringLayer.maxValue = maxValue
561584
self.ringLayer.viewStyle = viewStyle

UICircularProgressRingTests/UICircularProgressRingTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class UICircularProgressRingTests: XCTestCase {
5454
// Check the defaults for the view, change them, then make sure they changed
5555
XCTAssertNil(progressRing.delegate)
5656

57+
XCTAssertEqual(progressRing.fullCircle, true)
58+
progressRing.fullCircle = false
59+
XCTAssertEqual(progressRing.fullCircle, false)
60+
5761
XCTAssertEqual(progressRing.value, 0)
5862
progressRing.value = 50
5963
XCTAssertEqual(progressRing.value, 50)

docs/Classes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h4>Declaration</h4>
123123
</article>
124124
</div>
125125
<section class="footer">
126-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
126+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
127127
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
128128
</section>
129129
</body>

docs/Classes/UICircularProgressRingView.html

+51-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,56 @@ <h4>Declaration</h4>
168168
</li>
169169
</ul>
170170
</div>
171+
<div class="task-group">
172+
<div class="task-name-container">
173+
<a name="/Circle%20Properties"></a>
174+
<a name="//apple_ref/swift/Section/Circle Properties" class="dashAnchor"></a>
175+
<a href="#/Circle%20Properties">
176+
<h3 class="section-name">Circle Properties</h3>
177+
</a>
178+
</div>
179+
<ul class="item-container">
180+
<li class="item">
181+
<div>
182+
<code>
183+
<a name="/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb"></a>
184+
<a name="//apple_ref/swift/Property/fullCircle" class="dashAnchor"></a>
185+
<a class="token" href="#/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb">fullCircle</a>
186+
</code>
187+
</div>
188+
<div class="height-container">
189+
<div class="pointer-container"></div>
190+
<section class="section">
191+
<div class="pointer"></div>
192+
<div class="abstract">
193+
<p>Whether or not the progress ring should be a full circle.</p>
194+
195+
<p>What this means is that the outer ring will always go from 0 - 360 degrees and the inner ring will be calculated accordingly depending on current value.</p>
196+
197+
<p><a href='#important' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='important'>Important</h2></p>
198+
199+
<p>Default = true</p>
200+
201+
<p>When this property is true any value set for <code><a href="../Classes/UICircularProgressRingView.html#/s:vC22UICircularProgressRing26UICircularProgressRingView8endAngleV12CoreGraphics7CGFloat">endAngle</a></code> will be ignored.</p>
202+
203+
<p><a href='#author' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='author'>Author:</h2></p>
204+
205+
<p>Luis Padron</p>
206+
207+
</div>
208+
<div class="declaration">
209+
<h4>Declaration</h4>
210+
<div class="language">
211+
<p class="aside-title">Swift</p>
212+
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">fullCircle</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span></code></pre>
213+
214+
</div>
215+
</div>
216+
</section>
217+
</div>
218+
</li>
219+
</ul>
220+
</div>
171221
<div class="task-group">
172222
<div class="task-name-container">
173223
<a name="/Value%20Properties"></a>
@@ -1294,7 +1344,7 @@ <h4>Parameters</h4>
12941344
</article>
12951345
</div>
12961346
<section class="footer">
1297-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
1347+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
12981348
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
12991349
</section>
13001350
</body>

docs/Protocols.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h4>Declaration</h4>
119119
</article>
120120
</div>
121121
<section class="footer">
122-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
122+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
123123
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
124124
</section>
125125
</body>

docs/Protocols/UICircularProgressRingDelegate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ <h4>Parameters</h4>
151151
</article>
152152
</div>
153153
<section class="footer">
154-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
154+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
155155
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
156156
</section>
157157
</body>

docs/docsets/UICircularProgressRing.docset/Contents/Resources/Documents/Classes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h4>Declaration</h4>
123123
</article>
124124
</div>
125125
<section class="footer">
126-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
126+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
127127
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
128128
</section>
129129
</body>

docs/docsets/UICircularProgressRing.docset/Contents/Resources/Documents/Classes/UICircularProgressRingView.html

+51-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,56 @@ <h4>Declaration</h4>
168168
</li>
169169
</ul>
170170
</div>
171+
<div class="task-group">
172+
<div class="task-name-container">
173+
<a name="/Circle%20Properties"></a>
174+
<a name="//apple_ref/swift/Section/Circle Properties" class="dashAnchor"></a>
175+
<a href="#/Circle%20Properties">
176+
<h3 class="section-name">Circle Properties</h3>
177+
</a>
178+
</div>
179+
<ul class="item-container">
180+
<li class="item">
181+
<div>
182+
<code>
183+
<a name="/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb"></a>
184+
<a name="//apple_ref/swift/Property/fullCircle" class="dashAnchor"></a>
185+
<a class="token" href="#/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb">fullCircle</a>
186+
</code>
187+
</div>
188+
<div class="height-container">
189+
<div class="pointer-container"></div>
190+
<section class="section">
191+
<div class="pointer"></div>
192+
<div class="abstract">
193+
<p>Whether or not the progress ring should be a full circle.</p>
194+
195+
<p>What this means is that the outer ring will always go from 0 - 360 degrees and the inner ring will be calculated accordingly depending on current value.</p>
196+
197+
<p><a href='#important' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='important'>Important</h2></p>
198+
199+
<p>Default = true</p>
200+
201+
<p>When this property is true any value set for <code><a href="../Classes/UICircularProgressRingView.html#/s:vC22UICircularProgressRing26UICircularProgressRingView8endAngleV12CoreGraphics7CGFloat">endAngle</a></code> will be ignored.</p>
202+
203+
<p><a href='#author' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='author'>Author:</h2></p>
204+
205+
<p>Luis Padron</p>
206+
207+
</div>
208+
<div class="declaration">
209+
<h4>Declaration</h4>
210+
<div class="language">
211+
<p class="aside-title">Swift</p>
212+
<pre class="highlight"><code><span class="kd">@IBInspectable</span> <span class="n">open</span> <span class="k">var</span> <span class="nv">fullCircle</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span></code></pre>
213+
214+
</div>
215+
</div>
216+
</section>
217+
</div>
218+
</li>
219+
</ul>
220+
</div>
171221
<div class="task-group">
172222
<div class="task-name-container">
173223
<a name="/Value%20Properties"></a>
@@ -1294,7 +1344,7 @@ <h4>Parameters</h4>
12941344
</article>
12951345
</div>
12961346
<section class="footer">
1297-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
1347+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
12981348
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
12991349
</section>
13001350
</body>

docs/docsets/UICircularProgressRing.docset/Contents/Resources/Documents/Protocols.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h4>Declaration</h4>
119119
</article>
120120
</div>
121121
<section class="footer">
122-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
122+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
123123
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
124124
</section>
125125
</body>

docs/docsets/UICircularProgressRing.docset/Contents/Resources/Documents/Protocols/UICircularProgressRingDelegate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ <h4>Parameters</h4>
151151
</article>
152152
</div>
153153
<section class="footer">
154-
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-16)</p>
154+
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-24)</p>
155155
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
156156
</section>
157157
</body>

0 commit comments

Comments
 (0)