Core Animation - 完成块
来源:互联网 发布:云南进出口贸易数据 编辑:程序博客网 时间:2024/06/06 05:32
什么是完成块呢?这类似于我们使用block完成事务后的回调,在完成既定的事物后出发的某种操作,拿上一篇隐式动画中的改变颜色来说可以为他设定一个完成块,在颜色变换之后将色块旋转90度:
//begin a new transaction [CATransaction begin]; //set the animation duration to 1 second [CATransaction setAnimationDuration:1.0]; //add the spin animation on completion [CATransaction setCompletionBlock:^{ //rotate the layer 90 degrees CGAffineTransform transform = self.colorLayer.affineTransform; transform = CGAffineTransformRotate(transform, M_PI_2); self.colorLayer.affineTransform = transform;}];//randomize the layer background colorCGFloat red = arc4random() / (CGFloat)INT_MAX;CGFloat green = arc4random() / (CGFloat)INT_MAX;CGFloat blue = arc4random() / (CGFloat)INT_MAX;self.colorLayer.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0].CGCo //commit the transaction[CATransaction commit];
根据完成块概念,即完成颜色改变后触发,所以旋转动画出现在颜色入栈出栈后,同时由于用默认的事物做变换,未设置旋转动画的时间,所以默认为0.25s。
查看地址:https://github.com/codeliu6572/CATransaction
0 0
- Core Animation - 完成块
- Core Animation Basics-Core Animation Programming Guide (1)
- Core Animation - 视觉效果<一>
- Core Animation - 视觉效果<二>
- Core Animation - 视觉效果<三>
- Core Animation - 变换<一>
- Core Animation - 变换<二>
- Core Animation - 变换<三>
- Core Animation - 变换<四>
- Core Animation - 变换<五>
- Core Animation - 爆炸效果
- core animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- docker 私有 registry 透过 nginx 反向代理
- WTL9在VS2013中配置过程及向导脚本发生错误时的解决方法
- Fragment疑问
- jquery uploadify+java
- 基于Android淡入淡出弹幕实现
- Core Animation - 完成块
- 数组类运算的实现
- 关于一些不同寻常的tabBar的使用
- iOS学习之iOS沙盒(sandbox)机制和文件操作(一)
- 【BZOJ1007】[HNOI2008]水平可见直线【半平面交】
- js中的prototype和基于prototype的继承总结
- 对MVC的理解?为什么要用MVC?在Cocoa中MVC是怎么实现的?你还熟悉其他的OC设计模式或别的设计模式吗
- Java中Arrays.asList的使用
- unexpected element (uri:"", local:"sean:person"). Expected elements are <{http://sean.com}person>