I would like to animate a curtain, which gets opened. I have two images: one for the left and one for the right side of the curtain (depicted in red). I wou开发者_StackOverflowld like to smoothly slide them away with Core Animation. For what animation type should I look for? How do I achieve a realistic sliding style?
Regards,
Stefan
alt text http://img.skitch.com/20100627-8ytxrbe64ccbruj49c2pbs7kt2.png
I'm not sure why people are suggesting using a translation. If all you need to do is slide the images, simply call -setCenter on each image view inside an animation block. Like this:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[leftCurtainImageView setCenter:pointOffScreenLeft];
[rightCurtainImageView setCenter:pointOffScreenRight];
[UIView commitAnimations];
Where pointOffScreenLeft, and pointOffScreenRight are calculated something like:
CGPoint pointOffScreenLeft = CGPointMake(
-[leftCurtainImageView bounds].size.width,
[leftCurtainImageView frame].origin.y);
CGPoint pointOffScreenRight = CGPointMake(
[rightCurtainImageView frame].origin.x +
[rightCurtainImageView bounds].size.width,
[leftCurtainImageView frame].origin.y);
These calculations assume that the curtains are positioned at the far left and far right edges respectively of their containing view.
The easiest solution would be to have to imageview or CGLayers and then use CGAffineTransformTranslate in an animation block to slide them off screen.
Man
After a long search. The only way I could find is this.
https://github.com/Ciechan/BCMeshTransformView
精彩评论