本文主要是介绍CAKeyframeAnimation-关键帧动画,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//关键帧动画 CAKeyframeAnimation
- (void)keyAnimation{CALayer *layer =[CALayer layer];layer.bounds = CGRectMake(0, 0, 100, 100);layer.position = CGPointMake(100,100);layer.backgroundColor = [UIColor yellowColor].CGColor;[self.view.layer addSublayer:layer];CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];anim.keyPath = @"position";anim.removedOnCompletion = NO;anim.fillMode = kCAFillModeForwards;anim.duration = 2.0;CGMutablePathRef path = CGPathCreateMutable();CGPathAddEllipseInRect(path, NULL, CGRectMake(100, 100, 200, 200));anim.path = path;CGPathRelease(path);// 设置动画的执行节奏// kCAMediaTimingFunctionEaseInEaseOut : 一开始比较慢, 中间会加速, 临近结束的时候, 会变慢anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];anim.delegate = self;[layer addAnimation:anim forKey:nil];}
这篇关于CAKeyframeAnimation-关键帧动画的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!