相关代码展示:

- (IBAction)toggleRoundCorners:(id)sender {

[CATransaction setDisableActions:![_enableAnimations isOn]];

[CATransaction setAnimationDuration:_animationDuration];

[_layer setCornerRadius:([_layer cornerRadius] == 0.0 ? 25.0 : 0.0)];

}

- (IBAction)toggleColor:(id)sender {

[CATransaction setDisableActions:![_enableAnimations isOn]];

[CATransaction setAnimationDuration:_animationDuration];

[_layer setBackgroundColor:([_layer backgroundColor] == [UIColor blueColor].CGColor ? [UIColor greenColor].CGColor : [UIColor blueColor].CGColor)];

}

- (IBAction)toggleBorder:(id)sender {

[CATransaction setDisableActions:![_enableAnimations isOn]];

[CATransaction setAnimationDuration:_animationDuration];

[_layer setBorderWidth:([_layer borderWidth] == 0.0 ? 10 : 0.0)];

}

- (IBAction)toggleOpacity:(id)sender {

[CATransaction setDisableActions:![_enableAnimations isOn]];

[CATransaction setAnimationDuration:_animationDuration];

[_layer setOpacity:([_layer opacity] == 1.0 ? 0.2 : 1.0)];

}

- (IBAction)toggleSize:(id)sender

{

[CATransaction setDisableActions:![_enableAnimations isOn]];

[CATransaction setAnimationDuration:_animationDuration];

CGRect layerBounds = _layer.bounds;

layerBounds.size.width  = (layerBounds.size.width == layerBounds.size.height) ? 250.0 : 200.0;

[_layer setBounds:layerBounds];

BTSAnchorPointLayer *anchorPointLayer = [[_layer sublayers] objectAtIndex:0];

[anchorPointLayer setPosition:BTSCalculateAnchorPointPositionForLayer(_layer)];

}

- (void)beginAnimatingLayer

{

// Here we are creating an explicit animation for the layer's "transform" property.

// - The duration (in seconds) is controlled by the user.

// - The repeat count is hard coded to go "forever".

CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

[pulseAnimation setDuration:_animationDuration];

[pulseAnimation setRepeatCount:MAXFLOAT];

// The built-in ease in/ ease out timing function is used to make the animation look smooth as the layer

// animates between the two scaling transformations.

[pulseAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

// Scale the layer to half the size

CATransform3D transform = CATransform3DMakeScale(0.50, 0.50, 1.0);

// Tell CA to interpolate to this transformation matrix

[pulseAnimation setToValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]];

[pulseAnimation setToValue:[NSValue valueWithCATransform3D:transform]];

// Tells CA to reverse the animation (e.g. animate back to the layer's transform)

[pulseAnimation setAutoreverses:_autoreverses];

// Finally... add the explicit animation to the layer... the animation automatically starts.

[_layer addAnimation:pulseAnimation forKey:kBTSPulseAnimation];

}

- (void)endAnimatingLayer

{

[_layer removeAnimationForKey:kBTSPulseAnimation];

}

Core Animation演示的更多相关文章

  1. 老司机带你走进Core Animation

    为什么时隔这么久我又回来了呢? 回来圈粉. 开玩笑的,前段时间ipv6被拒啊,超级悲剧的,前后弄了好久,然后需求啊什么的又超多,所以写好的东西也没有时间整理.不过既然我现在回来了,那么这将是一个井喷的 ...

  2. IOS Core Animation Advanced Techniques的学习笔记(五)

    第六章:Specialized Layers   类别 用途 CAEmitterLayer 用于实现基于Core Animation粒子发射系统.发射器层对象控制粒子的生成和起源 CAGradient ...

  3. iOS——Core Animation 知识摘抄(三)

    原文地址:http://www.cocoachina.com/ios/20150105/10827.html CAShapeLayer CAShapeLayer是一个通过矢量图形而不是bitmap来绘 ...

  4. iOS - Core Animation 核心动画

    1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...

  5. IOS动画(Core Animation)总结 (参考多方文章)

    一.简介 iOS 动画主要是指Core Animation框架.官方使用文档地址为:Core Animation Guide. Core Animation是IOS和OS X平台上负责图形渲染与动画的 ...

  6. Core Animation简介

    一.Core Animation简介 * Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代 ...

  7. Core Animation学习总结

    文件夹: The Layer Beneath The Layer Tree(图层树) The Backing Image(寄宿层) Layer Geometry(图层几何学) Visual Effec ...

  8. iOS开发 - Core Animation 核心动画

    Core Animation Core Animation.中文翻译为核心动画,它是一组很强大的动画处理API,使用它能做出很炫丽的动画效果.并且往往是事半功倍. 也就是说,使用少量的代码就能够实现很 ...

  9. 一、Core Animation简介

    一.Core Animation简介 * Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代 ...

随机推荐

  1. Untiy PoolManager随手记

    用法,1是获取,2是清除, 问题是这个池到底能做什么用 首先用这个池生成的对象是在池节点下使用,而不是取出来用(可以取出来用,直接transform.parent赋值就可以) 疑问,池里面的节点时什么 ...

  2. 洛谷P2568 GCD(莫比乌斯反演)

    传送门 这题和p2257一样……不过是n和m相同而已…… 所以虽然正解是欧拉函数然而直接改改就行了所以懒得再码一遍了2333 不过这题卡空间,记得mu开short,vis开bool //minamot ...

  3. [Xcode 实际操作]八、网络与多线程-(12)使用异步Post方式查询IP地址信息

    目录:[Swift]Xcode实际操作 本文将演示如何通过Post请求,异步获取IP地址信息. 异步请求与同步请求相比,不会阻塞程序的主线程,而会建立一个新的线程. 在项目导航区,打开视图控制器的代码 ...

  4. IT兄弟连 JavaWeb教程 JSP内置对象1

    JSP内置对象定义 JSP提供了由容器实现和管理的内置对象,也可以称之为隐含对象,这些内置对象不需要通过JSP页面编写来实例化,在所有的JSP页面中都可以直接使用,它们起到了简化页面的作用,JSP的内 ...

  5. 序列化 jprotobuf

    jprotobuf工作原理如下: 扫描类上的注解的信息,进行分析(与protobuf读取proto文件进行分析过程相似) 根据注解分析的结果,动态生成java代码进行protobuf序列化与反序列化的 ...

  6. 牛客寒假6-A.出题

    链接:https://ac.nowcoder.com/acm/contest/332/A 题意: 小B准备出模拟赛. 她把题目按难度分为四等,分值分别为6,7,8,9. 已知小B共出了m道题,共n分. ...

  7. LIS的简单应用:UVA-437

    上一次紫芝详细地介绍了动态规划中的经典问题LIS,今天我们抽出一个类似思想的简单题目进行实践练习. The Tower of Babylon(巴比伦塔) Perhaps you have heard ...

  8. AtCoder Regular Contest 078 C

    C - Splitting Pile Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement Snu ...

  9. Hive_Hive的管理_web界面方式

    端口:9999启动方式: hive --service hwi &通过浏览器访问:http://<IP地址>:9999/hwi/ 执行启动命令后,报错,找不到hive-hwi-*. ...

  10. 转 Linux SendMail发送邮件失败诊断案例(四)

    http://www.cnblogs.com/kerrycode/p/7826036.html