How do I simultaneously animate a UIImageView's image and the UIImageView itself?

后端 未结 4 1957
余生分开走
余生分开走 2020-12-16 08:26

The title may not be so clear, but what I want to do is to make the UIImageView display a series of images (sort of like a gif) and I do this by setting the animationI

4条回答
  •  别那么骄傲
    2020-12-16 09:02

    Your "basic" problem starts on this line:

    CABasicAnimation *moveAnimation = [CABasicAnimation animation];
    

    A CABasicAnimation object uses only a single keyframe. That means that the content of the layer that you're animating is drawn once, and then that image is used for the duration of the animation.

    Using a CAKeyframeAnimation as Seamus suggests is one way to deal with the problem -- a keyframe animation will redraw the content of the animated layer multiple times, so drawing successive images for each keyframe will animate the content as well as position.

提交回复
热议问题