相关代码展示:

- (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. C#异步调用的应用实践浅谈

    C#异步调用的应用实践最经公司工作需要调用一个外部的webservice,同时要将传出的数据进行保存,以自己以前的习惯,就打算逐步操作,失败啊,完全没考虑过用户体验效果,在同事指点下,意识到使用C#异 ...

  2. .netcore--Controller后台实现企业微信发送消息

    一.获得企业微信管理端权限,登录企业企业微信管理端界面,并创建应用,如下图中的[网站消息推送] 二.参见企业微信API文献,根据corpid=ID&corpsecret=SECRET(其中企业 ...

  3. iOS 利用模态视图实现带黑色蒙版的底部弹窗

    本demo仅适用于iOS8及以上系统. 本文将使用autolayout+storyboard来实现弹窗 第一步.storyboard创建界面 1.打开storyboard 拖一个UIViewcontr ...

  4. P3809【模板】后缀排序

    传送门 深入理解了一波后缀数组,这东西真的很妙诶,自己推感觉完全不现实,看来只能靠背代码了 这段时间就多敲敲,把板子记熟吧 代码: #include<cstdio> #include< ...

  5. VLAN-5-802.1Q-in-Q隧道

    Q-in-Q允许SP在跨越WAN服务时,保留802.1Q VLAN标签.由此,VLAN可以被拓展到多个地理分散的站点上.     入向SP交换机收到802.1Q数据帧,使用额外的802.1Q头部来标记 ...

  6. Java内置锁和简单用法

    一.简单的锁知识 关于内置锁 Java具有通过synchronized关键字实现的内置锁,内置锁获得锁和释放锁是隐式的,进入synchronized修饰的代码就获得锁,走出相应的代码就释放锁. jav ...

  7. Win10系统特别卡的一个原因

    我遇到的Win10特别卡的原因是它自带的一个杀毒软件 迈克菲(McAfee)导致的,在卸载之前电脑真的特别卡,打开一个窗口都卡,,卸载了之后瞬间感觉电脑飞起来了.... 当然还有很多原因会导致电脑卡, ...

  8. java emoji表情存储解决方案

    1.问题产生情况 我遇到这个问题是做微信开发的时候有些有用的头像用了微信的emoji表情,然而我的mysql数据库用的编码是utf8_general_ci,就是utf-8编码,结果也就报错误了. 2. ...

  9. 根据Content获取到ItemsControl中对应的Item

    /// <summary> /// 根据控件的值获取到对应的Item /// </summary> /// <typeparam name="T"&g ...

  10. 【Linux】VirtualBox网络配置桥接模式

    VirtualBox网络配置桥接模式 CentOS/RHEL (虚拟机)配置 # 基于桥接模式设置固定 ip cat >> /etc/sysconfig/network-scripts/i ...