@@ -14,7 +14,7 @@ import UIKit
1414private enum TKMoveDirection {
1515 case left
1616 case right
17- func toBool ( ) -> Bool {
17+ func toLeft ( ) -> Bool {
1818 switch self {
1919 case . left:
2020 return true
@@ -88,21 +88,21 @@ open class TKRubberPageControl : UIControl {
8888 }
8989
9090 // 手势
91- fileprivate var indexTap : UITapGestureRecognizer ?
91+ private var indexTap : UITapGestureRecognizer ?
9292 // 所有图层
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 ( )
9797
9898 // 大球缩放比例
99- fileprivate let bubbleScale : CGFloat = 1 / 3.0
99+ private let bubbleScale : CGFloat = 1 / 3.0
100100
101101 // 存储计算用的
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
106106
107107
108108 public init ( frame: CGRect , count: Int , config: TKRubberPageControlConfig = TKRubberPageControlConfig ( ) ) {
@@ -118,7 +118,7 @@ open class TKRubberPageControl : UIControl {
118118 setUpView ( )
119119 }
120120
121- fileprivate func setUpView( ) {
121+ private func setUpView( ) {
122122
123123 // 一些奇怪的位置计算
124124
@@ -202,7 +202,7 @@ open class TKRubberPageControl : UIControl {
202202
203203
204204 // 手势事件
205- @objc fileprivate func tapValueChange( _ ges: UITapGestureRecognizer ) {
205+ @objc private func tapValueChange( _ ges: UITapGestureRecognizer ) {
206206 let point = ges. location ( in: self )
207207 if point. y > yPointbegin && point. y < yPointEnd && point. x > xPointbegin && point. x < xPointEnd{
208208 let index = Int ( point. x - xPointbegin) / Int( styleConfig. smallBubbleMoveRadius)
@@ -211,7 +211,7 @@ open class TKRubberPageControl : UIControl {
211211 }
212212
213213 // Index值变化
214- fileprivate func changIndexToValue( _ valueIndex: Int ) {
214+ private func changIndexToValue( _ valueIndex: Int ) {
215215 var index = valueIndex
216216 if index >= numberOfpage { index = numberOfpage - 1 }
217217 if index < 0 { index = 0 }
@@ -222,7 +222,7 @@ open class TKRubberPageControl : UIControl {
222222
223223 // 小球动画
224224 for index in range{
225- let smallBubbleIndex = ( direction. toBool ( ) ) ? ( index - 1 ) : ( index)
225+ let smallBubbleIndex = ( direction. toLeft ( ) ) ? ( index - 1 ) : ( index)
226226 let smallBubble = smallBubbles [ smallBubbleIndex]
227227 smallBubble. positionChange ( direction,
228228 radius: styleConfig. smallBubbleMoveRadius / 2 ,
@@ -268,11 +268,11 @@ open class TKRubberPageControl : UIControl {
268268// MARK: - Small Bubble
269269private class TKBubbleCell : CAShapeLayer , CAAnimationDelegate {
270270
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
276276
277277 override init ( layer: Any ) {
278278 styleConfig = TKRubberPageControlConfig ( )
@@ -293,7 +293,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
293293 setupLayer ( )
294294 }
295295
296- fileprivate func setupLayer( ) {
296+ private func setupLayer( ) {
297297 frame = CGRect ( x: 0 , y: 0 , width: styleConfig. smallBubbleSize, height: styleConfig. smallBubbleSize)
298298
299299 bubbleLayer. path = UIBezierPath ( ovalIn: bounds) . cgPath
@@ -305,13 +305,13 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
305305 }
306306
307307 // beginTime 本来是留给小球轮播用的, 但是效果不好就没用了
308- internal func positionChange( _ direction: TKMoveDirection , radius: CGFloat , duration: CFTimeInterval , beginTime: CFTimeInterval ) {
308+ func positionChange( _ direction: TKMoveDirection , radius: CGFloat , duration: CFTimeInterval , beginTime: CFTimeInterval ) {
309309
310- let toLeft = direction. toBool ( )
310+ let toLeft = direction. toLeft ( )
311311 let movePath = UIBezierPath ( )
312312 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
315315 center. x += radius * ( toLeft ? - 1 : 1 )
316316 lastDirection = direction
317317
@@ -368,7 +368,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate {
368368 CATransaction . setAnimationDuration ( 0 )
369369 CATransaction . setDisableActions ( true )
370370 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 )
372372 position = point
373373 opacity = 1
374374 CATransaction . commit ( )
0 commit comments