Thursday, April 19, 2012

iOS5 combine CGAffineTransform with animationImages?

I'm pretty new to iOS animation and I'm wondering if it's possible to combine an transition between two images along with a translation animation of the UIImageView using CGAffineTransform?



In other words I have two images that I want to animate between, and then I want to apply a simultaneous translation so that the whole thing moves across the page while moving back and forth between the two images.



I know I can apply a CGAffineTransformConcat to combine two CGAffineTransforms such as a CGAffineTransformTranslate and something else. But I don't see a CGAffineTransform which allows me to transition to another UIImage.



The only way I know to animate between images is to use the UIImageView animationImages array combined with startAnimating. However, I don't know how to combine this with a translation like so:



UIImageView* textView = [[UIImageView alloc] initWithFrame:bunnyImage.frame]; 

textView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"bunnyclose.png"],
[UIImage imageNamed:@"bunnytalk.png"],
nil];

textView.animationDuration = 1.0;
textView.animationRepeatCount = 8;
[textView startAnimating];

[self.view addSubview:textView];


Any suggestions?





No comments:

Post a Comment