【发布时间】:2012-10-17 05:32:55
【问题描述】:
我的程序是产品的网格视图,单击时,图像会从原始位置动画到所需的目的地(视图控制器中的位置)。当我在 iPad 模拟器中运行它时,图像将立即开始动画,但当我在设备 (iPad) 中运行它时,它在开始动画之前给了我大约 1 秒的延迟..
这是我的代码。我正在使用贝塞尔路径。
[UIView animateWithDuration:1.1
animations:^{
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:cellImageView.center];
[movePath addQuadCurveToPoint:self.miniDropHereView.center
controlPoint:CGPointMake(self.miniDropHereView.center.x, cellImageView.center.y)];
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = NO;
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim, opacityAnim, nil];
animGroup.duration = 1;
[cellImageView.layer addAnimation:animGroup forKey:@"angelica"];
cellImageView.alpha = 0; //.0000000000000000000001;
self.animateProduct = animGroup;
self.cellImageViewGlobal = cellImageView;
self.animateProduct.delegate= self;
}
completion:^(BOOL finished){
cellImageView.alpha = 0.0000000000000000000001;
[cellImageView removeFromSuperview];
}];
}
我研究了如何在动画开始之前控制延迟。于是我改了第一行动画代码(具体如下)
[UIView animateWithDuration:1.1 delay: 0.0f
options: UIViewAnimationOptionCurveEaseInOut
animations:^{
但即使我没有指定延迟,动画的开始也会立即发生,在我点击产品之后(使用 iPad 模拟器时)。我不确定问题是否出在我的 iPad 上。有没有其他方法可以加快动画的开始?
谢谢。
【问题讨论】:
-
iPad 使用的 CPU 和内存系统比同时代的 Mac 慢。
-
谢谢.. 但是还有其他方法可以加快速度吗?就像修改我的代码的某些部分一样。或者添加一些有助于加速的东西?
标签: ipad animation core-animation bezier uibezierpath