0

I'm trying to make a small ui controlled animation (as described in this answer) and continue this animation after rotation. Due to autolayout issues I have to remove and add the whole layer on autorotate.

This works so far. My problem is, as I want continue the animation from the same position it was left off, it won't go anywhere prior to the state it was the moment it rotated.

e.g. the slider is at 0.5. The animation was added again (due to removal) and I've set the timeOffset corresponding to 0.5. The animation will go forward, but not backward.

I create my animation via:

let animatePhase = CABasicAnimation(keyPath: "lineDashPhase")
animatePhase.byValue = phaseLength
animatePhase.duration = 1.0
animatePhase.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animatePhase.repeatCount = Float.infinity

lineLayer.addAnimation(animatePhase, forKey: "marching ants")
lineLayer.speed = 0.0
lineLayer.timeOffset = 0.0;
lineLayer.beginTime = 0.0;

lineLayer is a CAShapeLayer.

On `layoutSubviews' I remove and recreate the layer.

What am I doing wrong?

Thanks

Community
  • 1
  • 1
Jan
  • 1,827
  • 2
  • 16
  • 29
  • What't the current value of the layers property when re-added, and how is the animation's to and from values (or by value) configured? – David Rönnqvist Jan 20 '15 at 13:08
  • I've added my creation code. What do you mean by current value? the timeOffset? – Jan Jan 20 '15 at 14:09

0 Answers0