How would i go about creating an image sequence with core animation. I would like to:
add image1 for 1 second then remove image
add image2 for 2 seconds then rem
The easiest way is to use CABasicAnimation for contents key:
CABasicAnimation *animation = [CABasicAnimation animation];
animation.fromValue = (id)[UIImage imageNamed:@"image1.png"].CGImage;
animation.toValue = (id)[UIImage imageNamed:@"image2.png"].CGImage;
animation.duration = 1.0f;
animation.repeatCount = HUGE_VAL;
// animation.autoreverses = YES;
[image1Layer addAnimation:animation forKey:@"contents"];
This animation will infinitely change the layer contents between image1 and image2. You may want to set autoreverses
property for smoother transitions - test animation either ways and choose the option you like the best.