
例如(伪代码);
// Begin animations// Set rotation animation curve to EaseInOut// Set position animation curve to linear// Make some changes to position// Make some change to the angle of rotation// Commit the animations
编辑:(下面建议的CAAnimationGroup方法) – 创建了2个单独的CABasicAnimations和一个CAAnimationGroup,但是动画没有启动.有任何想法吗?
CABasicAnimation *postionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];postionAnimation.timingFunction = [camediatimingFunction functionWithname:kcamediatimingFunctionlinear];postionAnimation.tovalue = [NSValue valueWithCGPoint:[self transformPointToWorldspaceFromVIEwSpace:self.spriteVIEw.position]];postionAnimation.delegate = self;CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.z"];rotationAnimation.timingFunction = [camediatimingFunction functionWithname:kcamediatimingFunctionEaseInEaSEOut];rotationAnimation.tovalue = [NSNumber numberWithfloat:self.spriteVIEw.angle -= M_PI_2];rotationAnimation.delegate = self;CAAnimationGroup *animationsGroup = [CAAnimationGroup animation];animationsGroup.duration = self.clockSpeed;animationsGroup.animations = [NSArray arrayWithObjects:postionAnimation,rotationAnimation,nil];// Perform the animation[self.spriteVIEw.layer addAnimation:animationsGroup forKey:nil];解决方法 最好的办法是使用多次调用animateWithDuration:delay:options:animations:completion:.在每次调用中使用不同的动画曲线,它们将并行运行.或者,使用不同的延迟值,您可以按顺序运行它们.
代码可能如下所示:
[UIVIEw animateWithDuration: .5 delay: 0 options: UIVIEwAnimationoptionCurveEaseInOut animations: ^{ vIEw1.center = CGPointMake(x,y); } completion: ^{ //code that runs when this animation finishes }];[UIVIEw animateWithDuration: .5 delay: .5 options: UIVIEwAnimationoptionCurvelinear animations: ^{ vIEw2.center = CGPointMake(x2,y2); } completion: ^{ //code that runs when this animation finishes }]; 如果使用CAAnimationGroups,则存在一些问题.
首先,动画组确定整个组的动画曲线.我不认为你可以为每个子动画指定不同的曲线(虽然我承认我没有尝试过.)
其次,如果您向组添加动画,则不会调用各个动画的代理.只调用动画组的委托方法.
总结以上是内存溢出为你收集整理的ios – 在同一动画中使用两个不同的UIViewAnimationCurves全部内容,希望文章能够帮你解决ios – 在同一动画中使用两个不同的UIViewAnimationCurves所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)