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"?> ...
随机推荐
- Linux环境下的定时任务(转载)
今天做了个数据库的备份脚本,顺便系统得学习一下Linux下定时执行脚本的设置.Linux下的定时执行主要是使用crontab文件中加入定制计划来执行,设置比Windows稍微复杂一些(因为没有图形界面 ...
- 自定义 Maven 的 repositories
有时,应用中需要一些比较新的依赖,而这些依赖并没有正式发布,还是处于milestone或者是snapshot阶段,并不能从中央仓库或者镜像站上下载到.此时,就需要 自定义Maven的repositor ...
- a 样式重置 常见用法
样式重置 a:link, a:visited, a:hover, a:active{ color: #fff; text-decoration: none; } 常见用法 ( rel=& ...
- sql server数据库中char、nchar、varchar、nvarchar的选择
在数据库中,字符型的数据是最多的,可以占到整个数据库的80%以上.为此正确处理字符型的数据,对于提高数据库的性能有很大的作用. 在字符型数据中,用的最多的就是Char与Varchar两种类型.前面的是 ...
- python爬虫-链家租房信息获取
#导入需要用到的模块 import requests import pymysql import time from bs4 import BeautifulSoup import tkinter a ...
- 自定义Spark Partitioner提升es-hadoop Bulk效率
http://www.jianshu.com/p/cccc56e39429/comments/2022782 和 https://github.com/elastic/elasticsearch-ha ...
- linux make virtual memory more efficient three components
Page Cache This is used to speed up access to images and data on disk. As pages are read into memory ...
- [置顶]使用scrapy_redis,自动实时增量更新东方头条网全站新闻
存储使用mysql,增量更新东方头条全站新闻的标题 新闻简介 发布时间 新闻的每一页的内容 以及新闻内的所有图片.项目文件结构. 这是run.py的内容 1 #coding=utf-8 2 from ...
- vue+ajax+bootstrap+python实现增删改
http://www.cnblogs.com/xwwin/p/5816527.html script src= " http://code.jquery.com/jquery.min.js ...
- 超级好用的C++万能头文件
#include<bits/stdc++.h>包含了目前c++所包含的所有头文件 对比: #include <iostream> #include <cstdio> ...