2016-12-01 141 views
0

我想在我的应用程序中拥有这种动画,这种情况下箭头形状可以在点击时转换为标记。斯威夫特的动画

这就是我使用以下

present work

func handleTransform(){ 

    let arrowPath = UIBezierPath() 
    arrowPath.move(to: CGPoint(x: 50, y: 0)) 
    arrowPath.addLine(to: CGPoint(x: 25, y: 75)) 
    arrowPath.addLine(to: CGPoint(x: 25, y: 75)) 
    arrowPath.addLine(to: CGPoint(x: 25, y: 45)) 
    arrowPath.addLine(to: CGPoint(x: 25, y: 35)) 
    arrowPath.close() 

    let progressLines = CAShapeLayer() 
    progressLines.path = arrowPath.cgPath 
    progressLines.strokeColor = UIColor.black.cgColor 
    progressLines.fillColor = UIColor.clear.cgColor 
    progressLines.lineWidth = 10.0 
    progressLines.lineCap = kCALineCapRound 

    self.view.layer.addSublayer(progressLines) 

    let animateStrokeEnd = CABasicAnimation(keyPath: "strokeEnd") 
    animateStrokeEnd.duration = 3.0 
    animateStrokeEnd.fromValue = 0.0 
    animateStrokeEnd.toValue = 1.0 

    progressLines.add(animateStrokeEnd, forKey: "animate stroke end animation") 

} 

代码具有在本流程中示出图像中的波纹管

在此图像的点击 arrow icon

它转换到该图像 Mark icon

+0

你有此按钮后,尝试简单的“图像转换”开关图像被点击? – Vexy

+0

@EricAya我已经添加了我尝试做的代码,没有找到解决方案的地方 – SimpiMind

+0

@Vexy我不认为切换图像会起作用,因为第二个图像比第一个图像长一点 – SimpiMind

回答

1

我一直能不能解决,我与动画

+0

你能分享你的代码吗? – Vexy