Skip to content

Commit 12bb4c6

Browse files
committed
Minor fixes
1 parent 4373347 commit 12bb4c6

File tree

7 files changed

+131
-33
lines changed

7 files changed

+131
-33
lines changed

CHANGELOG.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ The changelog for `MSCircularSlider`. Summarized release notes can be found in t
33

44
------------------------
55

6-
## 1.1.0
6+
## 1.1.1 - 28-12-2017
7+
#### Fixed
8+
- Access control levels causing IB to crash
9+
- Podspec file configuration
10+
11+
## 1.1.0 - 27-12-2017
712
#### Added
813
- Support for using `snapToLabels` concurrently with `snapToMarkers` (snaps to the nearest label or marker)
914
- Multiple new members to `MSDoubleHandleCircularSlider` to customize each handle separately
1015

1116
#### Fixed
1217
- Issues and warnings risen from Swift updates, including errors caused by implicit access controls
1318

14-
## 1.0.1
15-
#### Fixed
16-
- Minor issues with Travis.ci
17-
1819

19-
## 1.0.0
20+
## 1.0.0 - 06-10-2017
2021
#### Fixed
21-
- Fixed many inconsistencies found in the pre-release version
22-
- Fixed Travis CI yml file that caused build fails
23-
- Fixed pod and podspec files
22+
- Many inconsistencies found in the pre-release version
23+
- Travis CI yml file that caused build fails
24+
- Pod and podspec files
2425

2526
#### Removed
2627
- Removed the unneeded pod.lock file

MSCircularSlider.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Pod::Spec.new do |s|
22
s.name = 'MSCircularSlider'
3-
s.version = '1.1.0'
3+
s.version = '1.1.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.authors = { 'ThunderStruct' => '[email protected]' }
66
s.summary = 'A full-featured circular slider for iOS applications'
77
s.homepage = 'https://github.com/ThunderStruct/MSCircularSlider'
88

99
# Source Info
1010
s.platform = :ios, '9.3'
11-
s.source = { :git => 'https://github.com/ThunderStruct/MSCircularSlider.git', :branch => "master", :tag => "1.1.0" }
11+
s.source = { :git => 'https://github.com/ThunderStruct/MSCircularSlider.git', :branch => "master", :tag => "1.1.1" }
1212
s.source_files = 'MSCircularSlider/*.{swift}'
1313

1414
s.requires_arc = true

MSCircularSlider/MSCircularSlider.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public class MSCircularSlider: UIControl {
502502
}
503503

504504
@discardableResult
505-
private func drawFilledCircle(ctx: CGContext, center: CGPoint, radius: CGFloat) -> CGRect {
505+
internal func drawFilledCircle(ctx: CGContext, center: CGPoint, radius: CGFloat) -> CGRect {
506506
let frame = CGRect(x: center.x - radius, y: center.y - radius, width: 2 * radius, height: 2 * radius)
507507
ctx.fillEllipse(in: frame)
508508
return frame
@@ -669,10 +669,11 @@ public class MSCircularSlider: UIControl {
669669
fixedAngle = maximumAngle - angle
670670
}
671671

672+
673+
var minDist = maximumAngle
674+
var newAngle = 0.0 as CGFloat
675+
672676
if snapToLabels {
673-
var minDist = maximumAngle
674-
var newAngle = 0.0 as CGFloat
675-
676677
for i in 0 ..< labels.count + 1 {
677678
let percentageAlongCircle = Double(i) / Double(labels.count - (fullCircle ? 0 : 1))
678679
let degreesToLbl = CGFloat(percentageAlongCircle) * maximumAngle
@@ -687,9 +688,6 @@ public class MSCircularSlider: UIControl {
687688
}
688689

689690
if snapToMarkers {
690-
var minDist = maximumAngle
691-
var newAngle = 0.0 as CGFloat
692-
693691
for i in 0 ..< markerCount + 1 {
694692
let percentageAlongCircle = Double(i) / Double(markerCount - (fullCircle ? 0 : 1))
695693
let degreesToMarker = CGFloat(percentageAlongCircle) * maximumAngle

MSCircularSlider/MSDoubleHandleCircularSlider+IB.swift

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
extension MSDoubleHandleCircularSlider {
1212

1313
//================================================================================
14-
// SECOND HANDLE PROPERTIES
14+
// DOUBLE HANDLE SLIDER PROPERTIES
1515
//================================================================================
1616

1717
@IBInspectable public var _minimumHandlesDistance: CGFloat {
@@ -31,4 +31,48 @@ extension MSDoubleHandleCircularSlider {
3131
secondCurrentValue = newValue
3232
}
3333
}
34+
35+
//================================================================================
36+
// SECOND HANDLE PROPERTIES
37+
//================================================================================
38+
39+
@IBInspectable public var _secondHandleType: Int { // Takes values from 0 to 3 only
40+
get {
41+
return secondHandleType.rawValue
42+
}
43+
set {
44+
if let temp = MSCircularSliderHandleType(rawValue: newValue) {
45+
secondHandleType = temp
46+
}
47+
}
48+
}
49+
50+
@IBInspectable public var _secondHandleColor: UIColor {
51+
get {
52+
return secondHandleColor
53+
}
54+
set {
55+
secondHandleColor = newValue
56+
}
57+
}
58+
59+
@IBInspectable public var _secondHandleEnlargementPoints: Int {
60+
get {
61+
return secondHandleEnlargementPoints
62+
}
63+
set {
64+
secondHandleEnlargementPoints = newValue
65+
}
66+
}
67+
68+
@IBInspectable public var _secondHandleHighlightable: Bool {
69+
get {
70+
return secondHandleHighlightable
71+
}
72+
set {
73+
secondHandleHighlightable = newValue
74+
}
75+
}
76+
77+
3478
}

MSCircularSlider/MSDoubleHandleCircularSlider.swift

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class MSDoubleHandleCircularSlider: MSCircularSlider {
3737
}
3838

3939

40-
// SECOND HANDLE'S PROPERTIES
40+
// DOUBLE HANDLE SLIDER PROPERTIES
4141
public var minimumHandlesDistance: CGFloat = 10 { // distance between handles
4242
didSet {
4343
let maxValue = CGFloat.pi * calculatedRadius * maximumAngle / 360.0
@@ -53,12 +53,8 @@ public class MSDoubleHandleCircularSlider: MSCircularSlider {
5353
}
5454
}
5555

56-
override public var handleHighlightable: Bool {
57-
didSet {
58-
secondHandle.isHighlightable = handleHighlightable
59-
setNeedsDisplay()
60-
}
61-
}
56+
// SECOND HANDLE'S PROPERTIES
57+
let secondHandle = MSCircularSliderHandle()
6258

6359
public var secondCurrentValue: Double { // second handle's value
6460
set {
@@ -78,12 +74,49 @@ public class MSDoubleHandleCircularSlider: MSCircularSlider {
7874

7975
public var secondAngle: CGFloat = 60 {
8076
didSet {
81-
//assert(secondAngle >= 0 && secondAngle <= 360, "secondAngle \(secondAngle) must be between 0 and 360 inclusive")
8277
secondAngle = max(0.0, secondAngle).truncatingRemainder(dividingBy: maximumAngle + 1)
8378
}
8479
}
8580

86-
let secondHandle = MSCircularSliderHandle()
81+
public var secondHandleColor: UIColor = .darkGray {
82+
didSet {
83+
setNeedsDisplay()
84+
}
85+
}
86+
87+
public var secondHandleType: MSCircularSliderHandleType = .largeCircle {
88+
didSet {
89+
setNeedsUpdateConstraints()
90+
setNeedsDisplay()
91+
}
92+
}
93+
94+
public var secondHandleEnlargementPoints: Int = 10 {
95+
didSet {
96+
setNeedsUpdateConstraints()
97+
setNeedsDisplay()
98+
}
99+
}
100+
101+
public var secondHandleHighlightable: Bool = true {
102+
didSet {
103+
secondHandle.isHighlightable = secondHandleHighlightable
104+
setNeedsDisplay()
105+
}
106+
}
107+
108+
// CALCULATED MEMBERS
109+
internal var secondHandleDiameter: CGFloat {
110+
switch handleType {
111+
case .smallCircle:
112+
return CGFloat(Double(lineWidth) / 2.0)
113+
case .mediumCircle:
114+
return CGFloat(lineWidth)
115+
case .largeCircle, .doubleCircle:
116+
return CGFloat(lineWidth + secondHandleEnlargementPoints)
117+
118+
}
119+
}
87120

88121
// OVERRIDDEN MEMBERS
89122
override public var maximumAngle: CGFloat {
@@ -123,7 +156,7 @@ public class MSDoubleHandleCircularSlider: MSCircularSlider {
123156

124157
// Draw the second handle
125158
let handleCenter = super.pointOnCircleAt(angle: secondAngle)
126-
secondHandle.frame = self.drawHandle(ctx: ctx!, atPoint: handleCenter, handle: secondHandle)
159+
secondHandle.frame = self.drawSecondHandle(ctx: ctx!, atPoint: handleCenter, handle: secondHandle)
127160
}
128161

129162
override func drawLine(ctx: CGContext) {
@@ -203,12 +236,35 @@ public class MSDoubleHandleCircularSlider: MSCircularSlider {
203236
// DRAWING METHODS
204237
//================================================================================
205238

206-
override func drawHandle(ctx: CGContext, atPoint handleCenter: CGPoint, handle: MSCircularSliderHandle) -> CGRect {
239+
internal func drawSecondHandle(ctx: CGContext, atPoint handleCenter: CGPoint, handle: MSCircularSliderHandle) -> CGRect {
207240
// Comment out the call to the super class and customize the second handle here
208241
// Must set calculatedColor for secondHandle in this case to set the handle's "highlight" if needed
209242
// TODO: add separate secondHandleDiameter, secondHandleColor, and secondHandleType properties
210243

211-
return super.drawHandle(ctx: ctx, atPoint: handleCenter, handle: handle)
244+
ctx.saveGState()
245+
var frame: CGRect!
246+
247+
// Highlight == 0.9 alpha
248+
let calculatedHandleColor = handle.isHighlightable && handle.isPressed ? secondHandleColor.withAlphaComponent(0.9) : secondHandleColor
249+
250+
// Handle color calculation
251+
if secondHandleType == .doubleCircle {
252+
calculatedHandleColor.set()
253+
drawFilledCircle(ctx: ctx, center: handleCenter, radius: 0.25 * secondHandleDiameter)
254+
255+
calculatedHandleColor.withAlphaComponent(0.7).set()
256+
257+
frame = drawFilledCircle(ctx: ctx, center: handleCenter, radius: 0.5 * secondHandleDiameter)
258+
}
259+
else {
260+
calculatedHandleColor.set()
261+
262+
frame = drawFilledCircle(ctx: ctx, center: handleCenter, radius: 0.5 * secondHandleDiameter)
263+
}
264+
265+
266+
ctx.saveGState()
267+
return frame
212268
}
213269

214270
//================================================================================

MSCircularSliderExample/MSCircularSlider/MSCircularSlider+IB.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,3 @@ extension MSCircularSlider {
228228

229229

230230

231-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MSCircularSlider
2-
[![Build Status](https://travis-ci.org/ThunderStruct/MSCircularSlider.svg?branch=master)](https://travis-ci.org/ThunderStruct/MSCircularSlider) [![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg)](https://github.com/ThunderStruct/MSCircularSlider) [![CocoaPods](https://img.shields.io/badge/pod-1.1.0-blue.svg)](https://cocoapods.org/pods/MSCircularSlider) [![License](https://img.shields.io/cocoapods/l/AFNetworking.svg)](https://github.com/ThunderStruct/MSCircularSlider/blob/master/LICENSE)
2+
[![Build Status](https://travis-ci.org/ThunderStruct/MSCircularSlider.svg?branch=master)](https://travis-ci.org/ThunderStruct/MSCircularSlider) [![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg)](https://github.com/ThunderStruct/MSCircularSlider) [![CocoaPods](https://img.shields.io/badge/pod-1.1.1-blue.svg)](https://cocoapods.org/pods/MSCircularSlider) [![License](https://img.shields.io/cocoapods/l/AFNetworking.svg)](https://github.com/ThunderStruct/MSCircularSlider/blob/master/LICENSE)
33

44
A fully `IBDesignable` and `IBInspectable` circular slider for iOS applications
55

0 commit comments

Comments
 (0)