Create a UIImageView
and set the property of animationImages
to an array of UIImage
s
Here is an example:
NSArray *animationFrames = [NSArray arrayWithObjects:
[UIImage imageWithName:@"image1.png"],
[UIImage imageWithName:@"image2.png"],
nil];
UIImageView *animatedImageView = [[UIImageView alloc] init];
animatedImageView.animationImages = animationsFrame;
[animatedImageView startAnimating];
If you're targeting iOS 5 you can do this directly in UIImage
without the UIImageView
using
+(UIImage *)animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration
for example,
[UIImage animatedImagesWithImages:animationFrames duration:10];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…