Core Animation演示
相关代码展示:
- (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演示的更多相关文章
- 老司机带你走进Core Animation
为什么时隔这么久我又回来了呢? 回来圈粉. 开玩笑的,前段时间ipv6被拒啊,超级悲剧的,前后弄了好久,然后需求啊什么的又超多,所以写好的东西也没有时间整理.不过既然我现在回来了,那么这将是一个井喷的 ...
- IOS Core Animation Advanced Techniques的学习笔记(五)
第六章:Specialized Layers 类别 用途 CAEmitterLayer 用于实现基于Core Animation粒子发射系统.发射器层对象控制粒子的生成和起源 CAGradient ...
- iOS——Core Animation 知识摘抄(三)
原文地址:http://www.cocoachina.com/ios/20150105/10827.html CAShapeLayer CAShapeLayer是一个通过矢量图形而不是bitmap来绘 ...
- iOS - Core Animation 核心动画
1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...
- IOS动画(Core Animation)总结 (参考多方文章)
一.简介 iOS 动画主要是指Core Animation框架.官方使用文档地址为:Core Animation Guide. Core Animation是IOS和OS X平台上负责图形渲染与动画的 ...
- Core Animation简介
一.Core Animation简介 * Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代 ...
- Core Animation学习总结
文件夹: The Layer Beneath The Layer Tree(图层树) The Backing Image(寄宿层) Layer Geometry(图层几何学) Visual Effec ...
- iOS开发 - Core Animation 核心动画
Core Animation Core Animation.中文翻译为核心动画,它是一组很强大的动画处理API,使用它能做出很炫丽的动画效果.并且往往是事半功倍. 也就是说,使用少量的代码就能够实现很 ...
- 一、Core Animation简介
一.Core Animation简介 * Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代 ...
随机推荐
- 【BZOJ1122】[POI2008] 账本BBB
→传送门← 正解: 贪心加单调队列优化 先粘贴一张别人写的被老师发下来给我们的题解(就是看着这张题解才写出来的) 下面是自己的话(一些具体操作过程): 把环拆成一条2*n的链,然后用优先队列来求出每一 ...
- 结束线程方法2 Java提供的中断机制
package com.mozq.thread.interrupt; /** * 注意:调用interrupt()方法,并不会结束线程. * 结束线程的语义:需要我们自己使用3个中断方法构建. * * ...
- 配置Gradle构建
构建基础配置 Android Studio包含一个顶级的构建文件和每个模块的构建文件.构建文件被称为 build.gradle,它是一个纯文本文件,它使用Groovy语法来配置由Android Gra ...
- Mysql优化配置
Mysql配置优化 一.环境介绍 Mysql版本:5.5.27 二.优化内容 字段 介绍 推荐值 skip-locking 避免MySQL的外部锁定,减少出错几率增强稳定性 back_log MySQ ...
- [android][windows][使用HAXM加速模拟器][不使用SDK manager]
网上找到了来使用HAXM,可惜我在sdk manager上下载不了,也使用过勾上[fetching...]那个选项,依然无效. 所以自己手动下载来安装和使用. 具体的教程可以参考http://blog ...
- 怎么样去优化我们的SQL语句
1.改写in 在SQL语言中,一个查询块可以作为另一个查询块中谓词的一个操作数.因此,SQL查询可以层层嵌套.例如在一个大型分布式数据库系统中,有订单表Order.订单信息表OrderDetail,如 ...
- Nacos部署中的一些常见问题汇总
开个帖子,汇总一下读者经常提到的一些问题 问题一:Ubuntu下启动Nacos报错 问题描述 使用命令sh startup.sh -m standalone启动报错: ./startup.sh: 78 ...
- 浅谈Hibernate中的三种数据状态
Hibernate中的三种数据状态:临时.持久.游离 1.临时态(瞬时态) 不存在于session中,也不存在于数据库中的数据,被称为临时态. 数据库中没有数据与之对应,超过作用域会被JVM垃圾回收器 ...
- HTML中实现Table表头点击升序/降序排序
题目:如下图,请实现表格信息的排序功能,当点击表头的属性区域,将表格信息进行排序切换功能,即第一次点击为降序排序,再一次点击进行升序排序. 姓名 力量 敏捷 智力 德鲁伊王 17 24 13 月之骑士 ...
- Windows系统下如何优化Android Studio
Android Studio将是Android开发大势所趋. 安装Android Studio时需注意的细节: · 找到安装目录bin目录下idea.properties 最后一行加入: dis ...