2014-10-28 4 views
2

내가 무엇을 달성하고자하는 것은 내가Swift- 애니메이션 CAshapeLayer의 획 색상

circleLayer = CAShapeLayer() 
circleLayer.path = circlePath.CGPath 
circleLayer.lineCap = kCALineCapRound 
circleLayer.fillColor = UIColor.clearColor().CGColor 
CABasicAnimation fill = CABasicAnimation. 
circleLayer.strokeColor = UIColor(red: 0.4, green: 1.0, blue: 0.2, alpha: 0.5).CGColor 
circleLayer.lineWidth = 20.0; 
circleLayer.lineJoin = kCALineJoinRound 
// Don't draw the circle initially 
circleLayer.strokeEnd = 0.0 

// Add the circleLayer to the view's layer's sublayers 
layer.addSublayer(circleLayer) 

을 만드는 오전 스트로크의 색상을 애니메이션 할 수있는 방법을 찾기 위해 노력하고있어이 생성되는 동안 (난 1 초 동안 생성), 색상 자체가 움직입니다.

+0

이 이전 질문 http://stackoverflow.com/questions/26602171/swift-animate-cashapelayer-stroke-color의 정확한 복제본처럼 보인다. 대답을 얻지 못하면 질문을 개선하고 더 많은 정보를 제공하십시오. 그러나 단순히 반복하지 마십시오. –

+0

@ MartinsR 나는 그것이 오 삭제 삭제 가르쳐. 이 마틴을 지울 수 있을까요? –

답변

1

용액을 발견했다. 즐겨. 당신은 물론 CAShapeLayer를 만든 후 :

 let animcolor = CABasicAnimation(keyPath: "strokeColor") 
     animcolor.fromValue   = UIColor.greenColor().CGColor 
     animcolor.toValue   = UIColor.orangeColor().CGColor 
     animcolor.duration   = 1.0; 
     animcolor.repeatCount  = 0; 
     animcolor.autoreverses  = true 
     circleLayer.addAnimation(animcolor, forKey: "strokeColor")