@@ -14,7 +14,7 @@ import UIKit
14
14
private enum TKMoveDirection {
15
15
case left
16
16
case right
17
- func toBool ( ) -> Bool {
17
+ func toLeft ( ) -> Bool {
18
18
switch self {
19
19
case . left:
20
20
return true
@@ -88,21 +88,21 @@ open class TKRubberPageControl : UIControl {
88
88
}
89
89
90
90
// 手势
91
- fileprivate var indexTap : UITapGestureRecognizer ?
91
+ private var indexTap : UITapGestureRecognizer ?
92
92
// 所有图层
93
- fileprivate var smallBubbles = [ TKBubbleCell] ( )
94
- fileprivate var backgroundLayer = CAShapeLayer ( )
95
- fileprivate var mainBubble = CAShapeLayer ( )
96
- fileprivate var backLineLayer = CAShapeLayer ( )
93
+ private var smallBubbles = [ TKBubbleCell] ( )
94
+ private var backgroundLayer = CAShapeLayer ( )
95
+ private var mainBubble = CAShapeLayer ( )
96
+ private var backLineLayer = CAShapeLayer ( )
97
97
98
98
// 大球缩放比例
99
- fileprivate let bubbleScale : CGFloat = 1 / 3.0
99
+ private let bubbleScale : CGFloat = 1 / 3.0
100
100
101
101
// 存储计算用的
102
- fileprivate var xPointbegin : CGFloat = 0
103
- fileprivate var xPointEnd : CGFloat = 0
104
- fileprivate var yPointbegin : CGFloat = 0
105
- fileprivate var yPointEnd : CGFloat = 0
102
+ private var xPointbegin : CGFloat = 0
103
+ private var xPointEnd : CGFloat = 0
104
+ private var yPointbegin : CGFloat = 0
105
+ private var yPointEnd : CGFloat = 0
106
106
107
107
108
108
public init ( frame: CGRect , count: Int , config: TKRubberPageControlConfig = TKRubberPageControlConfig ( ) ) {
@@ -118,7 +118,7 @@ open class TKRubberPageControl : UIControl {
118
118
setUpView ( )
119
119
}
120
120
121
- fileprivate func setUpView( ) {
121
+ private func setUpView( ) {
122
122
123
123
// 一些奇怪的位置计算
124
124
@@ -202,7 +202,7 @@ open class TKRubberPageControl : UIControl {
202
202
203
203
204
204
// 手势事件
205
- @objc fileprivate func tapValueChange( _ ges: UITapGestureRecognizer ) {
205
+ @objc private func tapValueChange( _ ges: UITapGestureRecognizer ) {
206
206
let point = ges. location ( in: self )
207
207
if point. y > yPointbegin && point. y < yPointEnd && point. x > xPointbegin && point. x < xPointEnd{
208
208
let index = Int ( point. x - xPointbegin) / Int( styleConfig. smallBubbleMoveRadius)
@@ -211,7 +211,7 @@ open class TKRubberPageControl : UIControl {
211
211
}
212
212
213
213
// Index值变化
214
- fileprivate func changIndexToValue( _ valueIndex: Int ) {
214
+ private func changIndexToValue( _ valueIndex: Int ) {
215
215
var index = valueIndex
216
216
if index >= numberOfpage { index = numberOfpage - 1 }
217
217
if index < 0 { index = 0 }
@@ -222,7 +222,7 @@ open class TKRubberPageControl : UIControl {
222
222
223
223
// 小球动画
224
224
for index in range{
225
- let smallBubbleIndex = ( direction. toBool ( ) ) ? ( index - 1 ) : ( index)
225
+ let smallBubbleIndex = ( direction. toLeft ( ) ) ? ( index - 1 ) : ( index)
226
226
let smallBubble = smallBubbles [ smallBubbleIndex]
227
227
smallBubble. positionChange ( direction,
228
228
radius: styleConfig. smallBubbleMoveRadius / 2 ,
@@ -268,11 +268,11 @@ open class TKRubberPageControl : UIControl {
268
268
// MARK: - Small Bubble
269
269
private class TKBubbleCell : CAShapeLayer , CAAnimationDelegate {
270
270
271
- fileprivate var bubbleLayer = CAShapeLayer ( )
272
- fileprivate let bubbleScale : CGFloat = 0.5
273
- fileprivate var lastDirection : TKMoveDirection !
274
- fileprivate var styleConfig : TKRubberPageControlConfig
275
- fileprivate var cachePosition = CGPoint . zero
271
+ var bubbleLayer = CAShapeLayer ( )
272
+ let bubbleScale : CGFloat = 0.5
273
+ var lastDirection : TKMoveDirection !
274
+ var styleConfig : TKRubberPageControlConfig
275
+ var cachePosition = CGPoint . zero
276
276
277
277
override init ( layer: Any ) {
278
278
styleConfig = TKRubberPageControlConfig ( )
@@ -293,7 +293,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
293
293
setupLayer ( )
294
294
}
295
295
296
- fileprivate func setupLayer( ) {
296
+ private func setupLayer( ) {
297
297
frame = CGRect ( x: 0 , y: 0 , width: styleConfig. smallBubbleSize, height: styleConfig. smallBubbleSize)
298
298
299
299
bubbleLayer. path = UIBezierPath ( ovalIn: bounds) . cgPath
@@ -305,13 +305,13 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
305
305
}
306
306
307
307
// beginTime 本来是留给小球轮播用的, 但是效果不好就没用了
308
- internal func positionChange( _ direction: TKMoveDirection , radius: CGFloat , duration: CFTimeInterval , beginTime: CFTimeInterval ) {
308
+ func positionChange( _ direction: TKMoveDirection , radius: CGFloat , duration: CFTimeInterval , beginTime: CFTimeInterval ) {
309
309
310
- let toLeft = direction. toBool ( )
310
+ let toLeft = direction. toLeft ( )
311
311
let movePath = UIBezierPath ( )
312
312
var center = CGPoint . zero
313
- let startAngle = toLeft ? 0 : CGFloat ( M_PI )
314
- let endAngle = toLeft ? CGFloat ( M_PI ) : 0
313
+ let startAngle = toLeft ? 0 : CGFloat . pi
314
+ let endAngle = toLeft ? CGFloat . pi : 0
315
315
center. x += radius * ( toLeft ? - 1 : 1 )
316
316
lastDirection = direction
317
317
@@ -368,7 +368,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
368
368
CATransaction . setAnimationDuration ( 0 )
369
369
CATransaction . setDisableActions ( true )
370
370
var point = cachePosition
371
- point. x += ( styleConfig. smallBubbleSize + styleConfig. bubbleXOffsetSpace) * CGFloat( lastDirection. toBool ( ) ? - 1 : 1 )
371
+ point. x += ( styleConfig. smallBubbleSize + styleConfig. bubbleXOffsetSpace) * CGFloat( lastDirection. toLeft ( ) ? - 1 : 1 )
372
372
position = point
373
373
opacity = 1
374
374
CATransaction . commit ( )
0 commit comments