用UIImageView作出动画效果

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    
    // 先把要播放的画面顺序排好
    NSMutableArray *imageArray = [[NSMutableArray alloc] init];
    for (int i = 0; i < 6; i++) {
        NSString *imageNames = [NSString stringWithFormat:@"run%d.tiff",i+1];
        UIImage *image = [UIImage imageNamed:imageNames];
        [imageArray addObject:image];
    }
    
    // 使用UIImageView 播放
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 120, 80)];
    imageView.animationImages = imageArray;
    // 播放一次动画所需的时间
    imageView.animationDuration = 1.0;
    // 设置播放的次数,其中0为一直播放
    imageView.animationRepeatCount = 0;
    // 开始动画
    [imageView startAnimating];
    
    [self.window addSubview:imageView];
    
    [self.window makeKeyAndVisible];
    return YES;
}

@end
原文地址:https://www.cnblogs.com/lantu1989/p/4601255.html