//

//  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. QQ、淘宝、阿里旺旺在线网页链接代码及详解 很实用

    你可直接到官网去生成代码,简单.方便,相信都能上网的你,对这不会有难度的,认识字的就行,赶紧去吧!   1.阿里旺旺官网: http://page.1688.com/html/wangwang/dow ...

  2. 将request.getParameterMap()转换成可操作的普通Map

    在java web项目中虽然可以通过request.getParameterMap()很轻松的获得参数Map,但得到的Map和普通Map是不一样的,是被锁定的,不能像操作常规Map那样进行put.ge ...

  3. 一些站点使用的服务器软件、js 框架大收集 [ 整理中 ]

    Chrome 的扩展应用 ChromeSnifferPlus ( 开源中国地址:http://www.oschina.net/p/chromesnifferplus,GitHub 地址:https:/ ...

  4. 推荐!国外程序员整理的 PHP 资源大全

    推荐!国外程序员整理的 PHP 资源大全 2014/08/02 · PHP, 工具与资源 · 8.5K 阅读 · 1 评论· php 分享到:0 与<YII框架>不得不说的故事—安全篇 R ...

  5. Bootstrap插件1--tooltip

    在引入bootstrap.js之前我们需要引入jquery的js文件 既然是bootstrap的插件,那么自然需要引用bootstrap.js和bootstrap.css这2个核心文件了 这里了主要介 ...

  6. 汇总10.4版本ArcGIS Server与ArcMap 安装+SDE+注册数据源(非破解)

    文档参考了Server技术支持部各位前辈的总结文档. win10 + Server 10.4 +  ArcMap 10.4 + Oracle instant client (32位 和 64位) 安装 ...

  7. delphi下如何获得不带扩展名的文件名?

    Edit1.Text:=ChangeFileExt(ExtractFileName(Application.ExeName),'') ; //获取到应用程序名后,将后缀名清空就可以啦.

  8. An Implementation of Double-Array Trie

    Contents What is Trie? What Does It Take to Implement a Trie? Tripple-Array Trie Double-Array Trie S ...

  9. js数组到后台转 list数组

    前台的数组格式是: [{"credit_record_certificate_id":"452","credit_record_type": ...

  10. [LeetCode]题解(python):032-Longest Valid Parentheses

    题目来源 https://leetcode.com/problems/longest-valid-parentheses/ Given a string containing just the cha ...