ios各种动画效果

最普通动画:
//开始动画
[UIView beginAnimations:nil context:nil];  
//设定动画持续时间
[UIView setAnimationDuration:2];
//动画的内容
frame.origin.x += 150;
[img setFrame:frame];
//动画结束
[UIView commitAnimations];

连续动画:一个接一个地显示一系列的图像
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"], nil];

UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages; //animationImages属性返回一个存放动画图片的数组
myAnimatedView.animationDuration = 0.25; //浏览整个图片一次所用的时间
myAnimatedView.animationRepeatCount = 0; // 0 = loops forever 动画重复次数
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[myAnimatedView release];

CATransition Public API动画:
CATransition *animation = [CATransition animation];
//动画时间
    animation.duration = 0.5f;
//先慢后快
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
//animation.removedOnCompletion = NO;

//各种动画效果
/*
kCATransitionFade;
kCATransitionMoveIn;
kCATransitionPush;z
kCATransitionReveal;
*/
/*
kCATransitionFromRight;
kCATransitionFromLeft;
kCATransitionFromTop;
kCATransitionFromBottom;
*/
//各种组合
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromRight;

[self.view.layer addAnimation:animation forKey:@"animation"];

CATransition Private API动画:
animation.type可以设定为以下效果
动画效果汇总:
/*
suckEffect(三角)

rippleEffect(水波抖动)

pageCurl(上翻页)

pageUnCurl(下翻页)

oglFlip(上下翻转)

cameraIris/cameraIrisHollowOpen/cameraIrisHollowClose  (镜头快门,这一组动画是有效果,只是很难看,不建议使用

而以下为则黑名单:

spewEffect: 新版面在屏幕下方中间位置被释放出来覆盖旧版面.

- genieEffect: 旧版面在屏幕左下方或右下方被吸走, 显示出下面的新版面 (阿拉丁灯神?).

- unGenieEffect: 新版面在屏幕左下方或右下方被释放出来覆盖旧版面.

- twist: 版面以水平方向像龙卷风式转出来.

- tubey: 版面垂直附有弹性的转出来.

- swirl: 旧版面360度旋转并淡出, 显示出新版面.

- charminUltra: 旧版面淡出并显示新版面.

- zoomyIn: 新版面由小放大走到前面, 旧版面放大由前面消失.

- zoomyOut: 新版面屏幕外面缩放出现, 旧版面缩小消失.

- oglApplicationSuspend: 像按"home" 按钮的效果.
*/

UIView Animations 动画:
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
//以下四种效果
/*
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];//oglFlip, fromLeft
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];//oglFlip, fromRight  
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
*/

[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
[UIView commitAnimations];
IOS4.0新方法:
方法: +(void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; //多一个动画结束后可以执行的操作.
//下边是嵌套使用,先变大再消失的动画效果.
[UIView animateWithDuration:1.25 animations:^{
CGAffineTransform newTransform = CGAffineTransformMakeScale(1.2, 1.2);
[firstImageView setTransform:newTransform];
[secondImageView setTransform:newTransform];}
completion:^(BOOL finished){
[UIView animateWithDuration:1.2 animations:^{
[firstImageView setAlpha:0];
[secondImageView setAlpha:0];} completion:^(BOOL finished){
[firstImageView removeFromSuperview];
[secondImageView removeFromSuperview]; }];
}];

//自定义的动画水波效果

CATransition * transition = [CATransition animation];
            
            transition.type = @"rippleEffect";
            
            [transition setSubtype:kCATransitionReveal];
            
            [transition setDuration:1.5];
            
            [_vvView.layer addAnimation:transition forKey:@"rippleEffect"];

iOS各种动画效果的更多相关文章

  1. iOS的动画效果类型及实现方法

    实现iOS漂亮的动画效果主要有两种方法, 一种是UIView层面的, 一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransit ...

  2. iOS 转盘动画效果实现

    代码地址如下:http://www.demodashi.com/demo/11598.html 近期公司项目告一段落,闲来无事,看到山东中国移动客户端有个转盘动画挺酷的.于是试着实现一下,看似简单,可 ...

  3. iOS开动画效果之──实现 pushViewController 默认动画效果

    在开发中,视图切换会常常遇到,有时我们不是基于导航控制器的切换,但实际开发中,有时需要做成push效果,下面将如何实现push和pop 默认动画效果代码实例: 一.push默认动画效果 CATrans ...

  4. ios animation 动画效果实现

    1.过渡动画 CATransition CATransition *animation = [CATransition animation]; [animation setDuration:1.0]; ...

  5. iOS简单动画效果:闪烁、移动、旋转、路径、组合

    #define kDegreesToRadian(x) (M_PI * (x) / 180.0) #define kRadianToDegrees(radian) (radian*180.0)/(M_ ...

  6. iOS - 毛玻璃动画效果

    声明全局变量 #define kMainBoundsHeight ([UIScreen mainScreen].bounds).size.height //屏幕的高度 #define kMainBou ...

  7. iOS火焰动画效果、图文混排框架、StackView效果、偏好设置、底部手势等源码

    iOS精选源码 高性能图文混排框架,构架顺滑的iOS应用. 使用OpenGLE覆盖阿尔法通道视频动画播放器视图. 可选最大日期截至当日日期的日期轮选器ChooseDatePicker 简单轻量的图片浏 ...

  8. iOS UIView动画效果 学习笔记

    //启动页动画 UIImageView *launchScreen = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; ...

  9. iOS启动动画效果实现

    原理 在window上加一个UIImageView它的图片和启动图的图片一样,然后再调整动画 运行展示 demo百度云连接:http://pan.baidu.com/s/1c0QcYu0 more:网 ...

随机推荐

  1. Debian8系统下,caffe的安装

    特此声明:本文不允许用于商业目的,允许转载(注明一下啦). 首先,官方的参考文献为:http://caffe.berkeleyvision.org/installation.html. 现在开始: 安 ...

  2. Gas Station

    Description: There are N gas stations along a circular route, where the amount of gas at station i i ...

  3. Android网络编程系列 一 JavaSecurity之JSSE(SSL/TLS)

    摘要:     Java Security在Java存在已久了而且它是一个非常重要且独立的版块,包含了很多的知识点,常见的有MD5,DigitalSignature等,而Android在Java Se ...

  4. iOS——为Xcode编译POCO C++静态库

    一.POCO C++ library简介 POCO C++ library是一个C++编写的跨平台库,主要实现网络连接.数据库管理以及服务器,适用于跨平台.嵌入式. 二.为Xcode编译POCO C+ ...

  5. 【服务器环境搭建-Centos】jdk的安装

    1.查看是否已安装openjdk 使用rpm命令查看是否已安装openjdk[root@linuxidc ~]# rpm -qa | grep java tzdata-java-2012c-.el6. ...

  6. Apache mod_jk

    http://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html http://tomcat.apache.org/co ...

  7. sql CHARINDEX函数

    CHARINDEX函数返回字符或者字符串在另一个字符串中的起始位置.CHARINDEX函数调用方法如下: CHARINDEX ( expression1 , expression2 [ , start ...

  8. SQL中SUBSTRING函数的用法

    功能:返回字符.二进制.文本或图像表达式的一部分 语法:SUBSTRING ( expression, start, length ) SQL 中的 substring 函数是用来抓出一个栏位资料中的 ...

  9. fushioncharts的使用教程

    FusionCharts 是使用javascript 实现统计图表的js组件:其官网地址:http://www.fusioncharts.com.其早期版本FusionCharts Free 是基于f ...

  10. TWaver HTML5 (2D)----数据元素

    概述 数据元素是数据模型的基本要素,用于描述图形网元,业务网元,或者纯数据.TWaver HTML5中所有数据元素都继承自twaver.Data.为不同功能的需求,预定义了三类数据类型:twaver. ...