Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit a1780e9

Browse files
fix warnings of M_PI
1 parent a85be35 commit a1780e9

8 files changed

Lines changed: 17 additions & 17 deletions

File tree

PullToRefreshKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'PullToRefreshKit'
11-
s.version = '0.4.0'
11+
s.version = '0.5.0'
1212
s.summary = 'A refresh library written with pure Swift 3'
1313
s.description = <<-DESC
1414
This is a pull to refresh library written by pure Swift 3. Using it you can add pull to refresh,pull to load more,pull left/right to view details within one line. Besides,it is quite easy to write a custom refresh view when using this lib.

PullToRefreshKit/CurveRefreshHeader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CurveRefreshHeader: UIView,RefreshableHeader{
4343
func stateDidChanged(_ oldState: RefreshHeaderState, newState: RefreshHeaderState) {
4444
if newState == .pulling && oldState == .idle{
4545
UIView.animate(withDuration: 0.4, animations: {
46-
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
46+
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
4747
})
4848
}
4949
if newState == .idle{

PullToRefreshKit/TaoBaoRefreshHeader.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
5353
func setUpCircleLayer(){
5454
let bezierPath = UIBezierPath(arcCenter: CGPoint(x: 20, y: 20),
5555
radius: 12.0,
56-
startAngle:CGFloat(-M_PI/2),
57-
endAngle: CGFloat(M_PI_2 * 3),
56+
startAngle:-CGFloat.pi/2,
57+
endAngle: CGFloat.pi/2.0 * 3.0,
5858
clockwise: true)
5959
self.circleLayer.path = bezierPath.cgPath
6060
self.circleLayer.strokeColor = UIColor.lightGray.cgColor
@@ -87,7 +87,7 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
8787
func didBeginRefreshingState(){
8888
self.circleLayer.strokeEnd = 0.95
8989
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
90-
rotateAnimation.toValue = NSNumber(value: M_PI * 2.0 as Double)
90+
rotateAnimation.toValue = NSNumber(value: Double.pi * 2.0)
9191
rotateAnimation.duration = 0.6
9292
rotateAnimation.isCumulative = true
9393
rotateAnimation.repeatCount = 10000000

PullToRefreshKit/YoukuRefreshHeader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class YoukuRefreshHeader:UIView,RefreshableHeader{
5656
func stateDidChanged(_ oldState: RefreshHeaderState, newState: RefreshHeaderState) {
5757
if newState == .pulling && oldState == .idle{
5858
UIView.animate(withDuration: 0.4, animations: {
59-
self.iconImageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
59+
self.iconImageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
6060
})
6161
}
6262
if newState == .idle{
@@ -70,7 +70,7 @@ class YoukuRefreshHeader:UIView,RefreshableHeader{
7070
self.iconImageView.isHidden = true
7171
self.rotatingImageView.isHidden = false
7272
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
73-
rotateAnimation.toValue = NSNumber(value: M_PI * 2.0 as Double)
73+
rotateAnimation.toValue = NSNumber(value: Double.pi * 2.0)
7474
rotateAnimation.duration = 0.8
7575
rotateAnimation.isCumulative = true
7676
rotateAnimation.repeatCount = 10000000

Source/Classes/ElasticRefreshControl.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ open class ElasticRefreshControl: UIView {
105105
let downCenter = CGPoint(x: centerX, y: totalHeight - downRadius - margin)
106106

107107
//偏移的角度
108-
let offSetAngle:CGFloat = CGFloat(M_PI_2 / 12.0)
108+
let offSetAngle:CGFloat = CGFloat.pi / 2.0 / 12.0
109109
//计算上面圆的左/右的交点坐标
110110
let upP1 = CGPoint(x: upCenter.x - upRadius * cosCGFloat(offSetAngle), y: upCenter.y + upRadius * sinCGFloat(offSetAngle))
111111
let upP2 = CGPoint(x: upCenter.x + upRadius * cosCGFloat(offSetAngle), y: upCenter.y + upRadius * sinCGFloat(offSetAngle))
@@ -119,17 +119,17 @@ open class ElasticRefreshControl: UIView {
119119

120120
//实际绘制
121121
context?.setFillColor(elasticTintColor.cgColor)
122-
context?.addArc(center: upCenter, radius: upRadius, startAngle: CGFloat(-M_PI)-offSetAngle, endAngle: offSetAngle, clockwise: false)
122+
context?.addArc(center: upCenter, radius: upRadius, startAngle: -CGFloat.pi - offSetAngle, endAngle: offSetAngle, clockwise: false)
123123
context?.move(to: CGPoint(x: upP1.x, y: upP1.y))
124124
context?.addQuadCurve(to: downP1, control: controPonintLeft)
125-
context?.addArc(center: downCenter, radius: downRadius, startAngle: CGFloat(-M_PI)-offSetAngle, endAngle: offSetAngle, clockwise: true)
125+
context?.addArc(center: downCenter, radius: downRadius, startAngle: -CGFloat.pi - offSetAngle, endAngle: offSetAngle, clockwise: true)
126126
context?.addQuadCurve(to: upP2, control: controPonintRight)
127127
context?.fillPath()
128128

129129
//绘制箭头
130130
context?.setStrokeColor(arrowColor.cgColor)
131131
context?.setLineWidth(lineWidth)
132-
context?.addArc(center: upCenter, radius: arrowRadius, startAngle: 0, endAngle: CGFloat(M_PI * 1.5), clockwise: false)
132+
context?.addArc(center: upCenter, radius: arrowRadius, startAngle: 0, endAngle: CGFloat.pi * 1.5, clockwise: false)
133133
context?.strokePath()
134134

135135
context?.setFillColor(arrowColor.cgColor)

Source/Classes/Header.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ open class DefaultRefreshHeader:UIView,RefreshableHeader, Tintable {
8484
return
8585
}
8686
UIView.animate(withDuration: 0.4, animations: {
87-
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
87+
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
8888
})
8989
}
9090
if oldState == RefreshHeaderState.pulling && newState == RefreshHeaderState.idle {
9191
textLabel.text = textDic[.pullToRefresh]
92-
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
92+
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
9393
return
9494
}
9595
UIView.animate(withDuration: 0.4, animations: {

Source/Classes/Left.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ open class DefaultRefreshLeft:UIView, RefreshableLeftRight, Tintable {
6262
return
6363
}
6464
UIView.animate(withDuration: 0.4, animations: {
65-
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
65+
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
6666
})
6767
textLabel.text = textDic[.releaseToAction]
6868
}
6969
if percent <= 1.0{
70-
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
70+
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
7171
return
7272
}
7373
textLabel.text = textDic[.scrollToAction]

Source/Classes/Right.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ open class DefaultRefreshRight:UIView, RefreshableLeftRight, Tintable {
5555
return
5656
}
5757
UIView.animate(withDuration: 0.4, animations: {
58-
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
58+
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
5959
})
6060
textLabel.text = textDic[.releaseToAction]
6161
}
6262
if percent <= 1.0{
63-
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
63+
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
6464
return
6565
}
6666
textLabel.text = textDic[.scrollToAction]

0 commit comments

Comments
 (0)