UIImageView有关的帧动画
纯代码:设置imageView帧动画
@interface ViewController ()
{
UIImageView *_imgView;
NSMutableArray<UIImage *> *_imageArr;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_imgView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 300, 300, 200)];
_imgView.image = [UIImage imageNamed:@"1.jpg"];
[self.view addSubview:_imgView];
// 1.1 实例化可变数组用来 加载所有的图片
_imageArr = [NSMutableArray array];
for (int i = 0; i<20; i++) {
// 获取图片的名称
NSString *imageName = [NSString stringWithFormat:@"%d", i+1];
// 创建UIImage对象
UIImage *image = [UIImage imageNamed:imageName];
// 加入数组
[_imageArr addObject:image];
}
// 开始按钮
UIButton *imgViewButtonStart = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[imgViewButtonStart setFrame:CGRectMake(20, 200, 200, 50)];
[imgViewButtonStart setTitle:@"开始动画" forState:UIControlStateNormal];
[imgViewButtonStart setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[imgViewButtonStart addTarget:self action:@selector(stratAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:imgViewButtonStart];
// 暂停按钮
UIButton *imgViewButtonStop = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[imgViewButtonStop setFrame:CGRectMake(200, 200, 200, 50)];
[imgViewButtonStop setTitle:@"停止动画" forState:UIControlStateNormal];
[imgViewButtonStop setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[imgViewButtonStop addTarget:self action:@selector(stopAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:imgViewButtonStop];
}
#pragma mark - 开始动画
- (void)stratAction {
// 设置动画图片
_imgView.animationImages = _imageArr;
// 设置动画的播放次数
_imgView.animationRepeatCount = 0;
// 设置播放时长
// 1秒30帧, 一张图片的时间 = 1/30 = 0.03333 20 * 0.0333
_imgView.animationDuration = 1.0;
// 开始动画
[_imgView startAnimating];
}
#pragma mark - 结束动画
- (void)stopAction {
[_imgView stopAnimating];
}
@end
UIImageView有关的帧动画的更多相关文章
- [Xcode 实际操作]六、媒体与动画-(13)使用UIImageView制作帧动画
目录:[Swift]Xcode实际操作 本文将演示如何将导入的序列图片,转换为帧动画. 在项目导航区打开资源文件夹[Assets.xcassets] [+]->[Import]->选择图片 ...
- 【iOS系列】-UIImageView帧动画相关属性介绍
UIImageView帧动画相关属性介绍 1:相关属性: //An array of UIImage objects to use for an animation.存放UIImage对象,会按顺序显 ...
- UIImageView帧动画相关属性和方法
@property(nonatomic,copy) NSArray *animationImages; 需要播放的序列帧图片数组(里面都是UIImage对象,会按顺序显示里面的图片) @propert ...
- iOS开发之 -- 帧动画的使用
在项目的开发过程中,我们经常会遇到使用动画的时候,比如我们在请求接口直接开始一个动画,请求结束后结束动画,下面我就给大家展示一个很方便的帧动画的用法: 代码如下: .h #import <Fou ...
- ios9--UIImageView的帧动画
// // ViewController.m // 05-UIImageView的帧动画 // #import "ViewController.h" @interface View ...
- 深入理解CSS3 Animation 帧动画
CSS3我在5年之前就有用了,包括公司项目都一直在很前沿的技术. 最近在写慕课网的七夕主题,用了大量的CSS3动画,但是真的沉淀下来仔细的去深入CSS3动画的各个属性发现还是很深的,这里就写下关于帧动 ...
- Android动画效果之Frame Animation(逐帧动画)
前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...
- android 帧动画,补间动画,属性动画的简单总结
帧动画——FrameAnimation 将一系列图片有序播放,形成动画的效果.其本质是一个Drawable,是一系列图片的集合,本身可以当做一个图片一样使用 在Drawable文件夹下,创建ani ...
- android 帧动画
首先在res/drawable/name1.xml/定义一组图片集合: <?xml version="1.0" encoding="utf-8"?> ...
随机推荐
- 智能边缘计算,让IoT有大智慧
丹棱君有话说:什么是智能边缘计算(Edge Computing)?别着急,它可是与你与我都有着千丝万缕的联系.物联网(IoT)的概念早已飞入寻常百姓家,在日常生活中的许多场景发挥着“智能”作用.比如, ...
- Hibernate HQL查询 插入 更新(update)实例
1.实体查询:有关实体查询技术,其实我们在先前已经有多次涉及,比如下面的例子:String hql=”from User user ”;List list=session.CreateQuery(hq ...
- spring boot 开发 org.springframework.context.ApplicationContextException: Unable to start web server;
Error starting ApplicationContext. To display the conditions report re-run your application with 'de ...
- 附加题找bug
private: void ReSize(int sz) { ) { return; } if(maxSize != sz) { T *arr = new T[sz]; if(arr == NULL) ...
- Tensorflow的基本概念与常用函数
Tensorflow一些常用基本概念与函数(一) 1.tensorflow的基本运作 为了快速的熟悉TensorFlow编程,下面从一段简单的代码开始: import tensorflow as tf ...
- Java基础十二--多态是成员的特点
Java基础十二--多态是成员的特点 一.特点 1,成员变量. 编译和运行都参考等号的左边. 覆盖只发生在函数上,和变量没关系. Fu f = new Zi();System.out.println( ...
- php5.4 的 arm 交叉编译
./configure --prefix=/h1root/usr/php --host=arm-linux --enable-libxml --with-mysql=mysqlnd --with-my ...
- 基于netty框架的socket长连接负载均衡解决方案
socket通讯的单机瓶颈 物联网的项目socket使用方式有两种: 短连接的socket请求 维持socket长连接的请求 对于socket短链接来说就好比是http请求,请求服务器,服务器返回数据 ...
- JSP页面出现乱码
Jsp文件中会出现下面所示的编码指定方式: <%@ page language="java" contentType="text/html; charset=UTF ...
- ural Ambitious Experiment 树状数组
During several decades, scientists from planet Nibiru are working to create an engine that would all ...