和Core Animation 相关的UIView 属性
Quartz Core 包含了框架 Core Animation 框架
通过 UIKit 使用 Core Animation
可以为每一个动画上下文赋予一个动画代理,负责在动画触发关键事件作出响应
[UIView beginAnimations:@"box-animation" context:nil]; [UIView setAnimationDuration:1]; box.backgroundColor = [UIColor redColor]; box.frame = CGRectMake(50.0, 50.0, 100, 100); box.alpha = 0.5; <span style="font-size:18px;"> [UIView commitAnimations];</span>
方法二,使用动画代码块 block生成
<span style="color:#000000;"> [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ box.backgroundColor = [UIColor redColor]; box.frame = CGRectMake(50.0, 50.0, 100, 100); box.alpha = 0.5; } completion:^(BOOL finished) { NSLog(@"finished"); }];</span>
CAAniamtion 派生类
CABasicAnimation
单一动画
CAKeyframeAnimation
关键帧
CATransitionAnimation
对整个layer 进行修改
CATransition
渐变效果,push fade等
CAAnimationGroup
多个动画组成动画组一起播放
CAAnimation属性:
delegate:
两个代理方法
removedOnCompletion
如果设置YES,动画一旦完成将被移除,默认YES
timingFunction
定义动画时间的过程:先快后慢、线性、先慢后快等
CAAnimation类方法
animation
创建CAAnimation实例
defaultValueForKey
返回对应key的value值
CAAnimation实例方法
shouldArchiveValueForKey:
delegate 方法
animationDidStart:
animationDidStop:finished:
粒子发生器 (以后遇到再研究)
IOS5引入
粒子是一个点,拥有单独的视图和图层
粒子们有一个共同的起点,这个起点叫做粒子发生器
粒子发生器拥有一组属性,定义了位置、形状、大小等信息
同时管理者一个列表,里面列出了将要发射的焰火。 每隔发射点,有大小、发射频率、速度等属性。
粒子发射点 CAEmitterLayer 属性
emitterPosition 定义发生器的位置
emitterShape
emitterModel
emitterCells
Demo 下载地址:https://github.com/caigee/iosdev_sample
下的DemoCoreGraphics
厚吾(http://blog.csdn.net/mangosnow)
本文遵循“署名-非商业用途-保持一致”创作公用协议