CAAnimation

来源:互联网 发布:中级程序员考证培训费 编辑:程序博客网 时间:2024/06/05 07:05

动画对象可以在一段时间内持续驱动属性值的变化。可以将动画对象加入CALayer实例,一旦加入,层就会开始执行动画指令。

动画对象CAAnimation是抽象类,必须使用它的某个具体子类。

CAPropertyAnimation是CAAnimation的子类,它通过加入修改层属性的功能来扩充父类。

CAPropertyAnimation也是抽象类,它的两个具体子类:CABasicAnimation和CAKeyFrameAnimation。这两个类经常使用到。



CABasicAnimation:下面代码加入到上一章CALayer代码中,实现透明度变化动画

 CABasicAnimation *fader = [CABasicAnimation animationWithKeyPath:@"opacity"];        [fader setDuration:2.0];        [fader setFromValue:[NSNumber numberWithFloat:1.0]];        [fader setToValue:[NSNumber numberWithFloat:0.0]];                [boxLayer addAnimation:fader forKey:@"BigFade"];


原创粉丝点击