美文网首页
核心动画

核心动画

作者: LennyKwok | 来源:发表于2015-09-20 09:45 被阅读0次

第一种:

CGContextRef context = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationDuration:kDuration];//动画时间

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];//第一个参数:动画类型

NSUInteger green = [[self.view subviews] indexOfObject:self.greenView];

NSUInteger blue = [[self.view subviews] indexOfObject:self.blueView];

[self.view exchangeSubviewAtIndex:green withSubviewAtIndex:blue];

[UIView setAnimationDelegate:self];

// 动画完毕后调用某个方法

//[UIView setAnimationDidStopSelector:@selector(animationFinished:)];

[UIView commitAnimations];

第二种:

CATransition *animation = [CATransition animation];

animation.delegate = self;

animation.duration = kDuration;

animation.timingFunction = UIViewAnimationCurveEaseInOut;

animation.type = kCATransitionFade;//动画类型

animation.subtype = kCATransitionFromLeft;//动画方向

NSUInteger green = [[self.view subviews] indexOfObject:self.greenView];

NSUInteger blue = [[self.view subviews] indexOfObject:self.blueView];

[self.view exchangeSubviewAtIndex:green withSubviewAtIndex:blue];

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

动画类型还有:

1.2.用字符串表示

2.    pageCurl            向上翻一页

3.    pageUnCurl          向下翻一页

4.    rippleEffect        滴水效果

5.    suckEffect          收缩效果,如一块布被抽走

6.    cube                立方体效果

7.    oglFlip            上下翻转效果

8.    cameraIrisHollowOpen  iphone相机打开效果

9.    cameraIrisHollowOpen 关闭相机的效果

10.*/

第三种:

[UIView animateWithDuration:1 animations:^{

[[self.view.subviews objectAtIndex:0] setAlpha:1];

[[self.view.subviews objectAtIndex:1] setAlpha:0];

NSUInteger green = [[self.view subviews] indexOfObject:self.greenView];

NSUInteger blue = [[self.view subviews] indexOfObject:self.blueView];

[self.view exchangeSubviewAtIndex:green withSubviewAtIndex:blue];

}];

还有其他类型的调用方法,这个是最简单的,可以加上其他的参数进行一些操作。

第二个参数是一个代码快,来执行VIEW的属性改变,系统会将视图从当前状态平滑的过度到最终状态(就是你做修改之后的状态)。

可以被改变的属性有:

frame

bounds

center

transform //可以实现3D/2D效果

alpha

backgroundColor

contentStretch

比如 self.view.layer.transform = CATransform3DMakeRotation(1, -1, -1, 1); 可以在代码中将整个VIEW动画旋转(这里只是一个例子,有效果,但是不怎么好看)

上面是3D变化,如果是2d的,那么就应该修改view上的transform ,而不应该按照上面的代码。

相关文章

  • IOS 核心动画CoreAniamation总结

    iOS 核心动画是基于CALayer层的动画,UIView动画是系统对核心动画的封装,核心动画相对UIView来说...

  • iOS基础 - 核心动画(转)

    iOS基础 - 核心动画 一、核心动画 l核心动画基本概念 l基本动画 l关键帧动画 l动画组 l转场动画 lCo...

  • iOS核心动画高级技巧 - 8

    iOS核心动画高级技巧 - 1iOS核心动画高级技巧 - 2iOS核心动画高级技巧 - 3iOS核心动画高级技巧 ...

  • iOS动画(Core Animation)

    1.核心动画(Core Animation):强大的动画API 核心动画所在的位置如下图 核心动画位于UIKit的...

  • IOS 常用动画的实现方式整理

    一、CoreAnimation(核心动画) 1.核心动画介绍 1.什么是核心动画 Core Animation可以...

  • UIview动画和核心动画的区别

    UIView和核心动画的区别 核心动画只能添加到CALayer,UIView没有办法使用核心动画 核心动画一切都是...

  • iOS-核心动画

    前言:核心动画的基础知识,包括基本动画、帧动画、转场动画相关知识。 一、核心动画(Core Animation) ...

  • iOS面试个人总结(1)

    动画 1.UIView动画与核心动画的区别? 核心动画只作用在layer. 核心动画修改的值都是假像.它的真实位置...

  • 再来看看动画

    动画一般有:UIKit动画和CoreAnimation(核心)动画 下面主要是核心动画的内容:http://www...

  • 一头扎进iOS核心动画(一)

    记录一下学习的笔记 核心动画 核心动画基本概念 基本动画 关键帧动画 动画组 转场动画 Core Animatio...

网友评论

      本文标题:核心动画

      本文链接:https://www.haomeiwen.com/subject/ibzbcttx.html