Skip to content

Commit e3dc1c9

Browse files
committed
Compatible with the last version
1 parent 808c0cb commit e3dc1c9

File tree

5 files changed

+88
-6
lines changed

5 files changed

+88
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ github "tbxark/TKSwitcherCollection"
5454

5555

5656
## Release History
57+
* 1.4.2
58+
add `IBDesignable`/`IBInspectable` support
5759
* 1.4.1
5860
bugs fixed
5961
* 1.4.0

TKSwitcherCollection.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "TKSwitcherCollection"
3-
s.version = "1.4.1"
3+
s.version = "1.4.2"
44
s.summary = "A animate switcher cllection in Swift."
55
s.license = { :type => 'MIT License', :file => 'LICENSE' } # 协议
66
s.homepage = "https://github.com/TBXark/TKSwitcherCollection"

TKSwitcherCollection/TKExchangeSwitch.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ open class TKExchangeSwitch: TKBaseSwitch {
116116
}
117117
}
118118

119+
// MARK: - Deprecated
120+
extension TKExchangeSwitch {
121+
@available(*, deprecated:3.0, message:"color is deprecated. Use lineColor, onColor, offColor instead ")
122+
var color: (background: UIColor, on: UIColor, off: UIColor) {
123+
set {
124+
if newValue.background != lineColor {
125+
lineColor = newValue.background
126+
}
127+
if newValue.on != onColor {
128+
onColor = newValue.on
129+
}
130+
if newValue.on != offColor {
131+
offColor = newValue.off
132+
}
133+
}
134+
get {
135+
return (lineColor, onColor, offColor)
136+
}
137+
}
138+
}
139+
119140
private class TKExchangeCircleView : UIView {
120141

121142
// MARK: - Property

TKSwitcherCollection/TKSimpleSwitch.swift

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,39 @@ import UIKit
1414

1515

1616

17+
@available(*, deprecated:3.0, message:"TKSimpleSwitchConfig is deprecated. ")
18+
public struct TKSimpleSwitchConfig {
19+
public var onColor : UIColor
20+
public var offColor : UIColor
21+
public var lineColor : UIColor
22+
public var circleColor : UIColor
23+
public var lineSize: Double
24+
25+
26+
27+
public init(onColor : UIColor = UIColor(red:0.341, green:0.914, blue:0.506, alpha:1),
28+
offColor : UIColor = UIColor(white: 0.9, alpha: 1),
29+
lineColor : UIColor = UIColor(white: 0.8, alpha: 1),
30+
circleColor : UIColor = UIColor.white,
31+
lineSize : Double = 10) {
32+
self.onColor = onColor
33+
self.offColor = offColor
34+
self.lineColor = lineColor
35+
self.circleColor = circleColor
36+
self.lineSize = lineSize
37+
38+
39+
}
40+
41+
}
42+
43+
1744

1845
@IBDesignable
1946
open class TKSimpleSwitch: TKBaseSwitch {
2047

21-
fileprivate var swichControl = CAShapeLayer()
22-
fileprivate var backgroundLayer = CAShapeLayer()
48+
private var swichControl = CAShapeLayer()
49+
private var backgroundLayer = CAShapeLayer()
2350

2451
// 是否加旋转特效
2552
@IBInspectable open var rotateWhenValueChange: Bool = false
@@ -148,8 +175,40 @@ open class TKSimpleSwitch: TKBaseSwitch {
148175
backgroundLayer.add(backgroundFillColorAnim, forKey: "Color")
149176
}
150177

151-
fileprivate func stateToFillColor(_ isOn:Bool) -> CGColor {
178+
private func stateToFillColor(_ isOn:Bool) -> CGColor {
152179
return isOn ? onColor.cgColor : offColor.cgColor
153180
}
154181

155182
}
183+
184+
185+
// MARK: - Deprecated
186+
extension TKSimpleSwitch {
187+
@available(*, deprecated:3.0, message:"config is deprecated. Use onColor, offColor, lineColor, circleColor, lineSize instead ")
188+
open var config: TKSimpleSwitchConfig {
189+
set {
190+
if newValue.onColor != onColor {
191+
onColor = newValue.onColor
192+
}
193+
if newValue.offColor != offColor {
194+
offColor = newValue.offColor
195+
}
196+
if newValue.lineColor != lineColor {
197+
lineColor = newValue.lineColor
198+
}
199+
if newValue.circleColor != circleColor {
200+
lineColor = newValue.lineColor
201+
}
202+
if newValue.lineSize != lineSize {
203+
lineSize = newValue.lineSize
204+
}
205+
}
206+
get {
207+
return TKSimpleSwitchConfig(onColor: onColor,
208+
offColor: offColor,
209+
lineColor: lineColor,
210+
circleColor: circleColor,
211+
lineSize: lineSize)
212+
}
213+
}
214+
}

TKSwitcherCollection/TKSmileSwitch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import UIKit
1616
open class TKSmileSwitch: TKBaseSwitch {
1717

1818
// MARK: - Poperty
19-
fileprivate var smileFace : TKSmileFaceView?
19+
private var smileFace : TKSmileFaceView?
2020

2121

2222
// MARK: - Init
@@ -123,7 +123,7 @@ private class TKSmileFaceView : UIView {
123123
}
124124

125125
// MARK: - Private Func
126-
fileprivate func setupLayers(){
126+
private func setupLayers(){
127127

128128
let facePath = UIBezierPath(ovalIn:CGRect(x: 0, y: 0, width: 100 * sizeScale, height: 100 * sizeScale))
129129
let eyePath = UIBezierPath(ovalIn:CGRect(x: 0, y: 0, width: 20 * sizeScale, height: 20 * sizeScale))

0 commit comments

Comments
 (0)