I'm programming on objective-c. Can I create an animation with CABasicAnimation for object that used 2 animations at the same time? For example, object is scaling and shaking at the same time.
Asked
Active
Viewed 520 times
1 Answers
0
Absolutely. In fact, you could do it with a CAKeyFrame, CABasic, or even a UIView animation. This should work great modified from this answer
- (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;
}];
}
-
If someone could format my code properly, I'd be much obliged seeig as I typed this out on an iPhone. – CodaFi May 30 '12 at 06:02