关闭

多张图片整合成连续动画的代码

标签: iphone开发
457人阅读 评论(0) 收藏 举报
分类:


把多张图片整合成连续动画,这恐怕是很多苹果开发者需要的功能。下面是单次播放和循环播放的代码。
animationImageView.animationImages = imageFrames;// imageFrames 是一个图片数组   animationImageView是一个imageview
[UIView setAnimationDelegate:self];
animationImageView.animationDuration = 0.75f; 
animationImageView.animationRepeatCount = 3; 
[animationImageView startAnimating];
shouldPlay = NO;
NSInteger timeout = 3;
[NSTimer scheduledTimerWithTimeInterval:timeout target:self selector:@selector(stopAnimation) userInfo:nil repeats:NO];


    循环播放的代码
UIImageView* animView= [[UIImageView alloc] initWithFrame:self.view.frame];
     animView.animationImages = [NSArray arrayWithObjects:    
                                 [UIImage imageNamed:@"01.gif"],
                                 [UIImage imageNamed:@"02.gif"],
                                 [UIImage imageNamed:@"03.gif"],nil];
     
     // all frames will execute in 1.75 seconds
     animView.animationDuration = 1.75;
     // repeat the annimation forever
     animView.animationRepeatCount = 0;
     // start animating
     [animView startAnimating];
     // add the animation view to the main window 
     [self.view addSubview:animView];
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:86134次
    • 积分:1389
    • 等级:
    • 排名:千里之外
    • 原创:22篇
    • 转载:160篇
    • 译文:1篇
    • 评论:2条
    文章分类
    最新评论