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

Commit

Permalink
fix warnings of M_PI
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMobileDeveloper committed Jun 29, 2017
1 parent a85be35 commit a1780e9
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion PullToRefreshKit.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PullToRefreshKit'
s.version = '0.4.0'
s.version = '0.5.0'
s.summary = 'A refresh library written with pure Swift 3'
s.description = <<-DESC
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.
Expand Down
2 changes: 1 addition & 1 deletion PullToRefreshKit/CurveRefreshHeader.swift
Expand Up @@ -43,7 +43,7 @@ class CurveRefreshHeader: UIView,RefreshableHeader{
func stateDidChanged(_ oldState: RefreshHeaderState, newState: RefreshHeaderState) {
if newState == .pulling && oldState == .idle{
UIView.animate(withDuration: 0.4, animations: {
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
})
}
if newState == .idle{
Expand Down
6 changes: 3 additions & 3 deletions PullToRefreshKit/TaoBaoRefreshHeader.swift
Expand Up @@ -53,8 +53,8 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
func setUpCircleLayer(){
let bezierPath = UIBezierPath(arcCenter: CGPoint(x: 20, y: 20),
radius: 12.0,
startAngle:CGFloat(-M_PI/2),
endAngle: CGFloat(M_PI_2 * 3),
startAngle:-CGFloat.pi/2,
endAngle: CGFloat.pi/2.0 * 3.0,
clockwise: true)
self.circleLayer.path = bezierPath.cgPath
self.circleLayer.strokeColor = UIColor.lightGray.cgColor
Expand Down Expand Up @@ -87,7 +87,7 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
func didBeginRefreshingState(){
self.circleLayer.strokeEnd = 0.95
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotateAnimation.toValue = NSNumber(value: M_PI * 2.0 as Double)
rotateAnimation.toValue = NSNumber(value: Double.pi * 2.0)
rotateAnimation.duration = 0.6
rotateAnimation.isCumulative = true
rotateAnimation.repeatCount = 10000000
Expand Down
4 changes: 2 additions & 2 deletions PullToRefreshKit/YoukuRefreshHeader.swift
Expand Up @@ -56,7 +56,7 @@ class YoukuRefreshHeader:UIView,RefreshableHeader{
func stateDidChanged(_ oldState: RefreshHeaderState, newState: RefreshHeaderState) {
if newState == .pulling && oldState == .idle{
UIView.animate(withDuration: 0.4, animations: {
self.iconImageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
self.iconImageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
})
}
if newState == .idle{
Expand All @@ -70,7 +70,7 @@ class YoukuRefreshHeader:UIView,RefreshableHeader{
self.iconImageView.isHidden = true
self.rotatingImageView.isHidden = false
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotateAnimation.toValue = NSNumber(value: M_PI * 2.0 as Double)
rotateAnimation.toValue = NSNumber(value: Double.pi * 2.0)
rotateAnimation.duration = 0.8
rotateAnimation.isCumulative = true
rotateAnimation.repeatCount = 10000000
Expand Down
8 changes: 4 additions & 4 deletions Source/Classes/ElasticRefreshControl.swift
Expand Up @@ -105,7 +105,7 @@ open class ElasticRefreshControl: UIView {
let downCenter = CGPoint(x: centerX, y: totalHeight - downRadius - margin)

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

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

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

context?.setFillColor(arrowColor.cgColor)
Expand Down
4 changes: 2 additions & 2 deletions Source/Classes/Header.swift
Expand Up @@ -84,12 +84,12 @@ open class DefaultRefreshHeader:UIView,RefreshableHeader, Tintable {
return
}
UIView.animate(withDuration: 0.4, animations: {
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
})
}
if oldState == RefreshHeaderState.pulling && newState == RefreshHeaderState.idle {
textLabel.text = textDic[.pullToRefresh]
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
return
}
UIView.animate(withDuration: 0.4, animations: {
Expand Down
4 changes: 2 additions & 2 deletions Source/Classes/Left.swift
Expand Up @@ -62,12 +62,12 @@ open class DefaultRefreshLeft:UIView, RefreshableLeftRight, Tintable {
return
}
UIView.animate(withDuration: 0.4, animations: {
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
})
textLabel.text = textDic[.releaseToAction]
}
if percent <= 1.0{
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
return
}
textLabel.text = textDic[.scrollToAction]
Expand Down
4 changes: 2 additions & 2 deletions Source/Classes/Right.swift
Expand Up @@ -55,12 +55,12 @@ open class DefaultRefreshRight:UIView, RefreshableLeftRight, Tintable {
return
}
UIView.animate(withDuration: 0.4, animations: {
self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001))
self.imageView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001)
})
textLabel.text = textDic[.releaseToAction]
}
if percent <= 1.0{
guard self.imageView.transform == CGAffineTransform(rotationAngle: CGFloat(-M_PI+0.000001)) else{
guard self.imageView.transform == CGAffineTransform(rotationAngle: -CGFloat.pi+0.000001) else{
return
}
textLabel.text = textDic[.scrollToAction]
Expand Down

0 comments on commit a1780e9

Please sign in to comment.