Core Animation is not working with “alpha” value
[CABasicAnimation animationWithKeyPath:@”opacity”]; UIView exposes this as alpha where as CALayer exposes this as opacity.
[CABasicAnimation animationWithKeyPath:@”opacity”]; UIView exposes this as alpha where as CALayer exposes this as opacity.
Have you set the removedOnCompletion property of the rotation animation to NO, e.g., rota.removedOnCompletion = NO; That should leave the presentation layer where it was when the animation finished. The default is YES, which will snap back to the model value, i.e., the behavior you describe. The fillMode should also be set, i.e., rota.fillMode = … Read more
Set the repeatCount to Float.infinity. This compiles and works. In all probability, HUGE_VALF was a legacy value in any case. Still, it’s a bit of a surprise that these numeric constant names are not seen by Swift. I did try importing <stdlib.h> in the bridging header but it didn’t help. But please see now Martin … Read more
No, this is the way you’re supposed to do it according to the documentation. Setting this property to HUGE_VALF will cause the animation to repeat forever. Update for Swift: HUGE_VALF is not exposed to Swift. However, my understanding from this page is that HUGE_VALF is intended to be infinity (in fact, INFINITY is defined as … Read more
Recently appeared Apple’s technical note QA1673 describes how to pause/resume layer’s animation. Pause and resume animations listing is below: -(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = pausedTime; } -(void)resumeLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer timeOffset]; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = 0.0; CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() … Read more
Shouldn’t you be using the [CAMediaTiming beginTime] property (reference)? See Customizing the Timing of an Animation in the Core Animation Programming Guide. CABasicAnimation *animation; animation.beginTime = CACurrentMediaTime() + 0.3; //0.3 seconds delay
Here’s the answer, it’s a combination of my answer and Krishnan’s. cabasicanimation.fillMode = kCAFillModeForwards; cabasicanimation.removedOnCompletion = NO; The default value is kCAFillModeRemoved. (Which is the reset behavior you’re seeing.)