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

Commit

Permalink
Version 1.4.2
Browse files Browse the repository at this point in the history
- Add new `fullCircle` property
- Update Xcode tests
- Update documentation
  • Loading branch information
Luis Padron committed Mar 24, 2017
1 parent e36568c commit b5d82ac
Show file tree
Hide file tree
Showing 18 changed files with 400 additions and 35 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 1.4.2 (latest)

- 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.
- Update some Xcode unit tests
- Update documentation to include new `fullCircle` property

#### Breaking changes in 1.4.2

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`.

# Version 1.4.1

- Fix bug where the default `valueIndicator` _'%'_ - was not set on initialization
Expand Down
2 changes: 1 addition & 1 deletion UICircularProgressRing.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "UICircularProgressRing"
s.version = "1.4.1"
s.version = "1.4.2"
s.summary = "A highly customizable circular progress bar for iOS written in Swift 3"

s.description = <<-DESC
Expand Down
28 changes: 19 additions & 9 deletions UICircularProgressRing/UICircularProgressRingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class UICircularProgressRingLayer: CAShapeLayer {
These properties are initialized in UICircularProgressRingView.
They're also assigned by mutating UICircularProgressRingView.
*/
@NSManaged var fullCircle: Bool

@NSManaged var value: CGFloat
@NSManaged var maxValue: CGFloat

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

let outerPath = UIBezierPath(arcCenter: center,
radius: outerRadius,
startAngle: startAngle.toRads,
endAngle: endAngle.toRads,
startAngle: start,
endAngle: end,
clockwise: true)

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

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

// Calculate the center difference between the end and start angle
let angleDiff: CGFloat = endAngle.toRads - startAngle.toRads
// Calculate how much we should draw depending on the value set
let arcLenPerValue = angleDiff / CGFloat(maxValue)
// The inner end angle some basic math is done
let innerEndAngle = arcLenPerValue * CGFloat(value) + startAngle.toRads
var innerEndAngle: CGFloat = 0.0

if fullCircle {
innerEndAngle = (360.0 / CGFloat(maxValue)) * CGFloat(value) + startAngle
} else {
// Calculate the center difference between the end and start angle
let angleDiff: CGFloat = endAngle - startAngle
// Calculate how much we should draw depending on the value set
let arcLenPerValue = angleDiff / CGFloat(maxValue)
// The inner end angle some basic math is done
innerEndAngle = arcLenPerValue * CGFloat(value) + startAngle
}

// The radius for style 1 is set below
// The radius for style 1 is a bit less than the outer, this way it looks like its inside the circle
Expand All @@ -204,7 +214,7 @@ class UICircularProgressRingLayer: CAShapeLayer {
let innerPath = UIBezierPath(arcCenter: center,
radius: radiusIn,
startAngle: startAngle.toRads,
endAngle: innerEndAngle,
endAngle: innerEndAngle.toRads,
clockwise: true)
innerPath.lineWidth = innerRingWidth
innerPath.lineCapStyle = innerCapStyle
Expand Down
23 changes: 23 additions & 0 deletions UICircularProgressRing/UICircularProgressRingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ import UIKit
*/
open weak var delegate: UICircularProgressRingDelegate?

// MARK: Circle Properties

/**
Whether or not the progress ring should be a full circle.

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.

## Important ##
Default = true

When this property is true any value set for `endAngle` will be ignored.

## Author:
Luis Padron

*/
@IBInspectable open var fullCircle: Bool = true {
didSet {
self.ringLayer.fullCircle = self.fullCircle
}
}

// MARK: Value Properties

/**
Expand Down Expand Up @@ -556,6 +578,7 @@ import UIKit
self.layer.contentsScale = UIScreen.main.scale
self.layer.shouldRasterize = true
self.layer.rasterizationScale = UIScreen.main.scale * 2
self.ringLayer.fullCircle = fullCircle
self.ringLayer.value = value
self.ringLayer.maxValue = maxValue
self.ringLayer.viewStyle = viewStyle
Expand Down
4 changes: 4 additions & 0 deletions UICircularProgressRingTests/UICircularProgressRingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class UICircularProgressRingTests: XCTestCase {
// Check the defaults for the view, change them, then make sure they changed
XCTAssertNil(progressRing.delegate)

XCTAssertEqual(progressRing.fullCircle, true)
progressRing.fullCircle = false
XCTAssertEqual(progressRing.fullCircle, false)

XCTAssertEqual(progressRing.value, 0)
progressRing.value = 50
XCTAssertEqual(progressRing.value, 50)
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
52 changes: 51 additions & 1 deletion docs/Classes/UICircularProgressRingView.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,56 @@ <h4>Declaration</h4>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Circle%20Properties"></a>
<a name="//apple_ref/swift/Section/Circle Properties" class="dashAnchor"></a>
<a href="#/Circle%20Properties">
<h3 class="section-name">Circle Properties</h3>
</a>
</div>
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb"></a>
<a name="//apple_ref/swift/Property/fullCircle" class="dashAnchor"></a>
<a class="token" href="#/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb">fullCircle</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Whether or not the progress ring should be a full circle.</p>

<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>

<p><a href='#important' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='important'>Important</h2></p>

<p>Default = true</p>

<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>

<p><a href='#author' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='author'>Author:</h2></p>

<p>Luis Padron</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<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>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Value%20Properties"></a>
Expand Down Expand Up @@ -1294,7 +1344,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/UICircularProgressRingDelegate.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,56 @@ <h4>Declaration</h4>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Circle%20Properties"></a>
<a name="//apple_ref/swift/Section/Circle Properties" class="dashAnchor"></a>
<a href="#/Circle%20Properties">
<h3 class="section-name">Circle Properties</h3>
</a>
</div>
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb"></a>
<a name="//apple_ref/swift/Property/fullCircle" class="dashAnchor"></a>
<a class="token" href="#/s:vC22UICircularProgressRing26UICircularProgressRingView10fullCircleSb">fullCircle</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Whether or not the progress ring should be a full circle.</p>

<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>

<p><a href='#important' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='important'>Important</h2></p>

<p>Default = true</p>

<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>

<p><a href='#author' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='author'>Author:</h2></p>

<p>Luis Padron</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<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>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Value%20Properties"></a>
Expand Down Expand Up @@ -1294,7 +1344,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Loading

0 comments on commit b5d82ac

Please sign in to comment.