UIKit封装的系统动画
简介
简单的位移动画
- (void)translateAnimation
{
[UIView animateWithDuration:1
delay:1
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
_imageView.center = CGPointMake(270, 410);
} completion:^(BOOL finished) {
NSLog(@"done");
}];
}
这个方法实现了通过设置属性的位移动画
增加仿射变换
- (void)transformAnimation
{
[UIView animateWithDuration:3
delay:1
options:UIViewAnimationOptionCurveEaseIn
animations:^{
_imageView.center = CGPointMake(270, 410);
_imageView.transform = CGAffineTransformRotate(CGAffineTransformScale(_imageView.transform, 0.6, 0.6), M_PI);
_imageView.alpha = 0.0;
} completion:^(BOOL finished) {
NSLog(@"done");
}];
}
在这个方法中,对UIImageView的transform属性设置进行了嵌套,在旋转180度的同时进行了缩放。由于设置了alpha,所以也还有一个渐渐消失的效果。
利用completion设置连续动画
- (void)transformAnimation
{
[UIView animateWithDuration:3
delay:1
options:UIViewAnimationOptionCurveEaseIn
animations:^{
_imageView.center = CGPointMake(270, 410);
_imageView.transform = CGAffineTransformRotate(CGAffineTransformScale(_imageView.transform, 0.6, 0.6), M_PI);
_imageView.alpha = 0.0;
} completion:^(BOOL finished) {
NSLog(@"done");
[UIView animateWithDuration:3
delay:0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
_imageView.center = CGPointMake(50, 50);
_imageView.transform = CGAffineTransformIdentity;
_imageView.alpha = 1.0;
} completion:nil];
}];
}
利用NSTimer完成连续动画
@interface ViewController ()
{
NSTimer *_timer;
NSInteger _step;
}
然后是方法
- (void)timerAnimation
{
_timer = [NSTimer scheduledTimerWithTimeInterval:0.05
target:self
selector:@selector(animateWithTimer)
userInfo:nil
repeats:YES];
} - (void)animateWithTimer
{
if (_step == 0) {
[_timer invalidate];
[_imageView removeFromSuperview];
} _imageView.transform = CGAffineTransformRotate(CGAffineTransformScale(_imageView.transform, 0.98, 0.98), ((10 * M_PI) / 180.0));
_imageView.alpha *= 0.98;
_step--;
}
虽然没有使用UIView封装的方法,但是也简单的实现了一个动画效果。
UIKit封装的系统动画的更多相关文章
- iOS_SN_push/pop转场动画封装和一般动画封装
封装类中的方法: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface AnimationE ...
- 第一百四十二节,JavaScript,封装库--运动动画和透明度动画
JavaScript,封装库--运动动画和透明度动画 /** yi_dong_tou_ming()方法,说明 * * yi_dong_tou_ming()方法,将一个元素,进行一下动画操作 * 1,x ...
- JS---案例:手风琴 (利用封装好的动画函数)
案例:手风琴 封装好的动画函数在common.js里面 //function getStyle(element, attr) {...} //function animate( ...
- 用虚拟机封装win10系统的一些记录
想用虚拟机封装一个WIN10企业LTSC,期间参考了IT天空小鱼儿的几大步骤一直到手动优化完,后面就自己用系统安装直接备份了一个.gho镜像.期间出过好多毛病,不过总算是成功实现了.注意点: 1.前面 ...
- iOS UIKit:viewController之动画(5)
当弹出一个view controller时,UIKit提供了一些标准转换动画,并且也支持用户自定义的动画效果. 1 UIView动画 UIView是自带动画实现功能,其中有两种方式实现: ...
- SDL封装的系统操作(转载)
Andrew Haung bluedrum@163.com SDL封装很多操作系统的功能,为了保证SDL程序可移植性,最好尽量用这一些封装函数,哪果没有的话,才使用各种操作本地函数. 对于如何封各个 ...
- 封装win7系统、制作win7GHO镜像、制作一个自定义的镜像文件具体步骤、制作Win10镜像gho
作者:导演你让灰太狼吃只羊 来源:CSDN 原文:https://blog.csdn.net/qq_35057426/article/details/83015516 版权声明:本文为博主原创文章,转 ...
- uiview封装的基本动画
基本动画的类型为 基本动画的节奏 UIViewAnimationOptionCurveEaseInOut = 0 << 16, // default UIViewAn ...
- js 封装一个均速动画函数
//动画函数---任意一个元素移动到指定的目标位置 //element为元素 target为位置 function carToon(element, target) { //设置一个定时器让他循环去增 ...
随机推荐
- mysql错误提示不是英语的解决办法
mysql提示突然就变成法语了,google了一下,找到了解决方法:打开my.ini文件,找到[mysqld]配置项如下 [mysqld] port explicit_defaults_for_tim ...
- zookeeper参考
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护.名字服务.分布式同步.组服务等. 我需要运行几个 ...
- Traveling
Problem J: Traveling Time Limit: 1 Sec Memory Limit: 32 MB Description SH likes traveling around th ...
- Web自动化基础分享
一.Selenium 简介 Selenium 是 ThoughtWorks 专门为 Web 应用程序编写的一个验收测试工具. 与其他测试工具相比,使用 Selenium 的最大好处是: Seleniu ...
- http://webhelp.esri.com/arcgisexplorer/2500/zh-CN/index.html#add_raster_data.htm
http://webhelp.esri.com/arcgisexplorer/2500/zh-CN/index.html#add_raster_data.htm
- IZ65534: 'JAVA.LANG.CLASSFORMATERROR' ERROR FOR A VALID IDENTIFIER
PAR status Closed as program error. Error description Error Message: The java class could not be loa ...
- Cloning Java objects using serialization
Sometimes you need to clone objects, and sometimes you can't use their clone method, and sometimes s ...
- Nand ECC校验和纠错原理及2.6.27内核ECC代码分析
ECC的全称是Error Checking and Correction,是一种用于Nand的差错检测和修正算法.如果操作时序和电路稳定性不存在问题的话,NAND Flash出错的时候一般不会造成整个 ...
- ARM Cortex M3(V7-M架构)硬件启动程序 二
解析 STM32 的启动过程 解析STM32的启动过程 当前的嵌入式应用程序开发过程里,并且C语言成为了绝大部分场合的最佳选择.如此一来main函数似乎成为了理所当然的起点——因为C程序往往从main ...
- git忽略特殊文件
忽略特殊文件 有些时候,你必须把某些文件放到Git工作目录中,但又不能提交它们,比如保存了数据库密码的配置文件啦,等等,每次git status都会显示Untracked files ...,有强迫症 ...