我正在使用此代碼刪除動畫我的UIView刪除按鈕刪除按鈕按下。 下面的代碼:如何將UIBezierPath與CoreAnimation一起使用?
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:icon.center];
[movePath addQuadCurveToPoint:senderView.center
controlPoint:CGPointMake(senderView.center.x, icon.center.y)];
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = YES;
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 = 2.0;
[icon.layer addAnimation:animGroup forKey:nil];
這實際上動畫UIView的給刪除按鈕,但它再次顯示在同一個地方了之後。
嘗試過,但動畫結束後仍然顯示UIView。 – Ashutosh 2012-02-03 18:57:53
嗯。也許動畫組需要相同的設置?它可能會凌駕其子動畫的屬性。 – 2012-02-03 19:39:42
無處不在。就像它在它開始的同一個地方停下來一樣。 – Ashutosh 2012-02-03 19:55:45