相关代码展示:

- (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. Kinect SDK(1):读取彩色、深度、骨骼信息并用OpenCV显示

    Kinect SDK 读取彩色.深度.骨骼信息并用OpenCV显示 一.原理说明 对于原理相信大家都明白大致的情况,因此,在此只说比较特别的部分. 1.1 深度流数据: 深度数据流所提供的图像帧中,每 ...

  2. SQL基础培训实战教程[全套]

    学习简介:林枫山根据网上搜索资料进行参考,编写制作的SQL Server实操学习教程,欢迎下载学习. 下载链接目录如下: 进度0-SQL基础语法    下载学习文档 进度1-建数据表-美化版-2018 ...

  3. native-echarts 在安卓上无法显示出来

    1.native-echarts 的配置是百度echarts 2.模拟器上试了很多次都显示不出来(具体不清楚,我的是这样) 3.真机测试可以显示图表,以下是配置: a.将node_modules\na ...

  4. ios 常用库

    SwiftHTTP       网络请求库 SwiftyJSON     json解析库 SnapKit          自动布局库 Kingfisher      图像加载库 WRCycleScr ...

  5. C# 面向对象之继承后初始化顺序

    使用继承之后当我们初始化一个子类时子类的初始化顺序为: (1)初始化类的实例字段 (2)调用基类的构造函数,如果没有指明基类则调用System.Object的构造函数; (3)调用子类的构造函数

  6. (洛谷P2512||bzoj1045) [HAOI2008]糖果传递 || 洛谷P4016 负载平衡问题 || UVA11300 Spreading the Wealth || (洛谷P3156||bzoj3293) [CQOI2011]分金币

    bzoj1045 洛谷P4016 洛谷P2512 bzoj3293 洛谷P3156 题解:https://www.luogu.org/blog/LittleRewriter/solution-p251 ...

  7. go time笔记

    package main import ( "time" "fmt" ) func main() { t := time.Now().UnixNano() fm ...

  8. python转换已转义的字符串

    python转换已转义的字符串 有时我们可能会获取得以下这样的字符串: >>> a = '{\\"name\\":\\"michael\\"} ...

  9. Windows忘记mysql的密码

    1.查看mysql的安装路径 show variables like "%char%"; 路径:C:\Program Files\MySQL\MySQL Server 5.7\ 2 ...

  10. (C#)asp_net调试错误解决方法收集(1)

    (C#)asp_net调试错误解决方法收集(1) 2007-11-2309:20 一.异常详细信息:System.InvalidOperationException:对于不返回任何键列信息的Selec ...