码迷,mamicode.com
首页 > 其他好文 > 详细

用UIImageView作出动画效果

时间:2015-06-26 01:37:49      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:

#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

 

用UIImageView作出动画效果

标签:

原文地址:http://www.cnblogs.com/lantu1989/p/4601255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!