0

我在objective-c上编程。我可以使用 CABasicAnimation 为同时使用 2 个动画的对象创建动画吗?例如,对象同时缩放和晃动。

4

1 回答 1

0

绝对地。实际上,您可以使用 CAKeyFrame、CABasic 甚至 UIView 动画来实现。这应该可以很好地从这个答案修改

- (void)earthquake:(UIView*)itemView
{
    CGFloat t = 2.0;

    CGAffineTransform leftQuake  = CGAffineTransformTranslate(CGAffineTransformIdentity, t, -t);
    CGAffineTransform rightQuake = CGAffineTransformTranslate(CGAffineTransformIdentity, -t, t);

    itemView.transform = leftQuake;  // starting point

    [UIView beginAnimations:@"earthquake" context:itemView];
    [UIView setAnimationRepeatAutoreverses:YES]; // important
    [UIView setAnimationRepeatCount:5];
    [UIView setAnimationDuration:0.07];
    [UIView setAnimationDelegate:self];
    itemView.transform = rightQuake; // end here & auto-reverse
    [UIView commitAnimations];
    [UIView animateWithDuration:1.00 animations:^{
         itemView.alpha = 0.0f;
    }];
}
于 2012-05-30T06:01:38.130 回答