CALayer的动画比较繁杂,有几种方式: CATransaction CAAnimation 本质上是一样的。先看CATransaction [CATransaction begin]; [CATransaction setAnimationDuration:3.0]; layer.shadowOffset = CGSizeMake(10, 10); [CATransaction commit]; 然后是CAAnimation,这个比较简单,可以用CABasicAnimation CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"shadowOffset"]; anim.toValue = [NSValue valueWithCGSize:CGSizeMake(10, 10)]; anim.duration = 3.0; anim.beginTime = 0; [self.layer addAnimation:anim forKey:@"animName"];
CALayer的动画比较繁杂,有几种方式:
本质上是一样的。先看CATransaction
然后是CAAnimation,这个比较简单,可以用CABasicAnimation