CABasicAnimation基础
简单使用
CABasicAnimation *positionAnima = [CABasicAnimation animationWithKeyPath:@"position.y"];
positionAnima.duration = 0.8;
positionAnima.fromValue = @(self.imageView.center.y);
positionAnima.toValue = @(self.imageView.center.y-30);
positionAnima.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
positionAnima.repeatCount = HUGE_VALF;//永不停止
positionAnima.repeatDuration = 2;
//下面两句代码可以防止动画结束后回到初始状
positionAnima.removedOnCompletion = NO;
positionAnima.fillMode = kCAFillModeForwards;
//END
[self.imageView.layer addAnimation:positionAnima forKey:@"AnimationMoveY"];
参考
参考链接一
参考链接二
本文标题:CABasicAnimation基础
本文链接:https://www.haomeiwen.com/subject/cbgkbttx.html
网友评论