layer动画。
CABasicAnimation--对应android 属性动画。
//透明动画。
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.beginTime = CACurrentMediaTime()+3;//开始时间
animation.fromValue = @1.0;//开始值。 animation.toValue = @0.1;//结束值 animation.duration = 2.0f;//时长 animation.fillMode = kCAFillModeBackwards;//填充模式 self.myLabel.layer addAnimation:animation forKey:@"opacity" ];
可设置参数:1.时长。2反向播放3.开始时间 。4.重复次数。5.重复播放间隔。6.快慢。7.播完后行为。留在那里还是移除。
/* The begin time of the object, in relation to its parent object, if * applicable. Defaults to 0. */ @property CFTimeInterval beginTime; 从什么时候开始执行动画。 /* The basic duration of the object. Defaults to 0. */ //动画时长 @property CFTimeInterval duration; /* The rate of the layer. Used to scale parent time to local time, e.g. * if rate is 2, local time progresses twice as fast as parent time. * Defaults to 1. */ //执行时,相对速度。 @property float speed; /* Additional offset in active local time. i.e. to convert from parent * time tp to active local time t: t = (tp - begin) * speed + offset. * One use of this is to "pause" a layer by setting `speed‘ to zero and * `offset‘ to a suitable value. Defaults to 0. */ @property CFTimeInterval timeOffset; /* The repeat count of the object. May be fractional. Defaults to 0. */ @property float repeatCount;//重复次数 /* The repeat duration of the object. Defaults to 0. */ @property CFTimeInterval repeatDuration;//多入后重播。 /* When true, the object plays backwards after playing forwards. Defaults * to NO. */ @property BOOL autoreverses;//自动反向播放 /* Defines how the timed object behaves outside its active duration. * Local time may be clamped to either end of the active duration, or * the element may be removed from the presentation. The legal values * are `backwards‘, `forwards‘, `both‘ and `removed‘. Defaults to * `removed‘. */ @property(copy) CAMediaTimingFillMode fillMode;//填充模式 @end /* `fillMode‘ options. */ CA_EXTERN CAMediaTimingFillMode const kCAFillModeForwards//执行填充。动画结束在哪儿就在哪儿。必须是不移除动画。 API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); CA_EXTERN CAMediaTimingFillMode const kCAFillModeBackwards//执行前就填充到相应位置或状态。 API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); CA_EXTERN CAMediaTimingFillMode const kCAFillModeBoth API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); CA_EXTERN CAMediaTimingFillMode const kCAFillModeRemoved API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
基本和android 一样一样的。