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"?> ...
随机推荐
- html js 捕捉鼠标右键事件,按下滚轮事件,左键点击事件
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- MVC修改视图的默认路径
概述:之前MVC5和之前的版本中,我们要想对View文件的路径进行控制的话,则必须要对IViewEngine接口的FindPartialView或FindView方法进行重写,所有的视图引擎都继承于该 ...
- 《剑指offer》第一题(重载赋值运算符)
//重载赋值运算符 #include <iostream> #include <cstring> using namespace std; class CMystring { ...
- Qt与FFmpeg联合开发指南(一)——解码(1):功能实现
前言:对于从未接触过音视频编解码的同学来说,使用FFmpeg的学习曲线恐怕略显陡峭.本人由于工作需要,正好需要在项目中使用.因此特地将开发过程总结下来.只当提供给有兴趣的同学参考和学习. 由于FFmp ...
- Codeforces 847I - Noise Level
847I - Noise Level 思路:bfs. 代码: #include<bits/stdc++.h> using namespace std; #define ll long lo ...
- win10 自己DIY的arp绑定小脚本
@echo off&mode con cols=80 lines=22&title ARP_bind Tools setlocal enabledelayedexpansion rem ...
- linux系统方面的知识
1.什么是Linux? 组成部分:硬件.内核.lib库.应用程序 硬件:工作中真正工作的组成部分是硬件 linux内核(kernel):管理硬件 Linux团队管理的版本 lib库:封 ...
- php fpm深度解析
摘自:https://www.cnblogs.com/wanghetao/p/3934350.html 当我们在谈到cgi的时候,我们在讨论什么 最早的Web服务器简单地响应浏览器发来的HTTP请求, ...
- JS冒泡排序的6种写法(武当雄风)
天下英雄出我辈,一入江湖岁月催.鸿图霸业谈笑间,不胜人生一场醉. 武当山上,一年一度的试道大会又开始了... 众武当弟子摩拳擦掌都想在此次试道大会上一展风采... 张三丰临终前曾留下一句话:试道大会采 ...
- thinkphp3.2 jquery ajax巧妙使用
1.做帐号管理的时候,我们去除一些重复的帐号是有必要的. 我使用的是jquery ajax 来和控制器进行传值.当我们跳转到我们要验证方法返回结果的时候,我们就可以使用php里的一个 0 为false ...