//

//  MJViewController.m

//  05-汤姆猫

//

//  Created by apple on 14-3-24.

//  Copyright (c) 2014年 itcast. All rights reserved.

//

#import "MJViewController.h"

@interface MJViewController ()

- (IBAction)drink;

- (IBAction)knock;

- (IBAction)rightFoot;

/** 这是一只显示图片的猫 */

@property (weak, nonatomic) IBOutlet UIImageView *tom;

@end

@implementation MJViewController

/** 播放动画 */

- (void)runAnimationWithCount:(int)count name:(NSString *)name

{

if (self.tom.isAnimating) return;

// 1.加载所有的动画图片

NSMutableArray *images = [NSMutableArray array];

for (int i = 0; i<count; i++) {

// 计算文件名

NSString *filename = [NSString stringWithFormat:@"%@_%02d.jpg", name, i];

// 加载图片

// imageNamed: 有缓存(传入文件名)

//        UIImage *image = [UIImage imageNamed:filename];

// imageWithContentsOfFile: 没有缓存(传入文件的全路径)

NSBundle *bundle = [NSBundle mainBundle];

NSString *path = [bundle pathForResource:filename ofType:nil];

UIImage *image = [UIImage imageWithContentsOfFile:path];

// 添加图片到数组中

[images addObject:image];

}

self.tom.animationImages = images;

// 2.设置播放次数(1次)

self.tom.animationRepeatCount = 1;

// 3.设置播放时间

self.tom.animationDuration = images.count * 0.05;

[self.tom startAnimating];

// 4.动画放完1秒后清除内存

CGFloat delay = self.tom.animationDuration + 1.0;

[self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:delay];

//    [self performSelector:@selector(clearCache) withObject:nil afterDelay:delay];

}

//- (void)clearCache

//{

////    self.tom.animationImages = nil;

//

//    [self.tom setAnimationImages:nil];

//}

- (IBAction)drink {

[self runAnimationWithCount:81 name:@"drink"];

//    if (self.tom.isAnimating) return;

//

//    // 1.加载所有的动画图片

//    NSMutableArray *images = [NSMutableArray array];

//

//    for (int i = 0; i<81; i++) {

//        // 计算文件名

//        NSString *filename = [NSString stringWithFormat:@"drink_%02d.jpg", i];

//        // 加载图片

//        UIImage *image = [UIImage imageNamed:filename];

//        // 添加图片到数组中

//        [images addObject:image];

//    }

//    self.tom.animationImages = images;

//

//    // 2.设置播放次数(1次)

//    self.tom.animationRepeatCount = 1;

//

//    // 3.设置播放时间

//    self.tom.animationDuration = images.count * 0.05;

//

//    [self.tom startAnimating];

}

- (IBAction)knock {

[self runAnimationWithCount:81 name:@"knockout"];

}

- (IBAction)rightFoot {

[self runAnimationWithCount:30 name:@"footRight"];

}

@end

uiimageView连续帧动画的更多相关文章

  1. [Xcode 实际操作]六、媒体与动画-(13)使用UIImageView制作帧动画

    目录:[Swift]Xcode实际操作 本文将演示如何将导入的序列图片,转换为帧动画. 在项目导航区打开资源文件夹[Assets.xcassets] [+]->[Import]->选择图片 ...

  2. IOS UIImageView的帧动画

    ● UIImageView可以让一系列的图片在特定的时间内按顺序显示 ● 相关属性解析: ● animationImages:要显示的图片(一个装着UIImage的NSArray) ● animati ...

  3. UIImageView有关的帧动画

    纯代码:设置imageView帧动画 @interface ViewController () { UIImageView *_imgView; NSMutableArray<UIImage * ...

  4. 【iOS系列】-UIImageView帧动画相关属性介绍

    UIImageView帧动画相关属性介绍 1:相关属性: //An array of UIImage objects to use for an animation.存放UIImage对象,会按顺序显 ...

  5. UIImageView帧动画相关属性和方法

    @property(nonatomic,copy) NSArray *animationImages; 需要播放的序列帧图片数组(里面都是UIImage对象,会按顺序显示里面的图片) @propert ...

  6. 帧动画 连续播放多张图片动画 以及ui动画 SoundPool

    drawable下有很多图片  可以 <?xml version="1.0" encoding="utf-8"?> <animation-li ...

  7. Android 逐帧动画

    原理: 逐帧动画是最简单的一种动画.原理就是把几张图片连续显示出来,以达到动画的效果.就相当于下面这种手绘翻页动画啦~ 实现: 1.需要建立一个animation-list来设置静态图片资源.持续时间 ...

  8. Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)

    1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...

  9. animation中的steps()逐帧动画

    在我们平时做宽高确定,需要背景图片切换的效果时,我如果用的是一张大的png图片.而且恰好是所有小图都是从左向右排列的,那么 我们只需测量出某一个小图距左侧有多少像素(x),然后我们banckgroun ...

随机推荐

  1. 【收集】JAVA多文件 上传文件接口代码 -兼容app

    原文:http://www.verydemo.com/demo_c143_i23854.html 我们在 multifile 中可以很容易的发现如何使用,这里就简单说说了,首先在页面上我们需要有这样几 ...

  2. poj 2186 tarjan求强连通分量

    蕾姐讲过的例题..玩了两天后才想起来做 貌似省赛之后确实变得好懒了...再努力两天就可以去北京玩了! 顺便借这个题记录一下求强连通分量的算法 1 只需要一次dfs 依靠stack来实现的tarjan算 ...

  3. Open vSwitch流表应用实战

    本文参考:Open vSwitch流表应用实战 一个通过改变流表下发而实现的互相通信实验. 实验目的: 掌握Open vSwitch下发流表操作: 掌握添加.删除流表命令以及设备通信的原理. 原理:. ...

  4. MVC问题

    将 <customErrors mode="Off" defaultRedirect="~/404.html">   mode 设置为off  就可 ...

  5. concurrency parallel 并发 并行

    Computer Systems A Programmer's Perspective Second Edition The general phenomenon of multiple flows ...

  6. 蓝牙BLE MTU规则与约定

    1. 问题引言: 想在gatt client上(一般是手机上)传输长一点的数据给gatt server(一般是一个Bluetooth smart设备,即只有BLE功能的设备),但通过 writeCha ...

  7. 读书笔记——《图解TCP/IP》(2/4)

    经典摘抄 第三章 数据链路 1.实际的通信媒介之间处理的却是电压的高低.光的闪灭以及电波的强弱等信号. 2.数据链路层的相关技术:MAC寻址.介质共享.非公有网络.分组交换.环路检测.VLAN等 3. ...

  8. mysql case when用法

    SELECT CASE WHEN `categoryid` =1THEN '参赛队员'ELSE '指导老师'END FROM `blog_article` WHERE 1

  9. crossvcl.com - 用VCL开发MacOS软件

    还没正式发布.用力戳 http://crossvcl.com/ 消息来源:Delphi G+ Group.具体信息还没完全披露,但是可以肯定的是,不是通过FireMonkey,而是通过原生的MacOS ...

  10. background和background-size

    今天偶遇一个小问题. 添加logo图片时, 由于不需要重新定位图片位置,就准备偷懒在间歇属性中省略background-position的属性,然而很不幸的是,结果却是酱紫的(谷歌浏览器): 不能加载 ...