Core Animation Image sequence

↘锁芯ラ 提交于 2019-12-03 00:44:06

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!