Reputation: 4246
I have 2 imageViews side by side, as shown in the figure:
I need to change these images by animating as a sliding view repetitively. I am doing this by using NSTimer.
The following is the code, I am using for creating the animation:
CATransition *animation = [CATransition animation];
[animation setDuration:1];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]] ;
[[imgVwTry layer] addAnimation:animation forKey:@"@asdf"];
However, the animation in the Left ImageView, starts from out of bounds of the image view. Same is shown in the following image:
Let me explain in a more clear way:
The animation that is occurring is overlapping with the Right ImageView. However, I want the animation to occur only in the area that is being specified for the LeftImageView. Something like this:
What change should I make in the animation code, s that i can remove the overlapping. Or is there any other way I can animate the images?
One more quick question, if I use UIImageView's startAnimation method, can I change the animation to slide animation?
Upvotes: 1
Views: 1048
Reputation: 61
You should set clipsToBounds to YES on the superview that holds the images you are talking about. This will stop the subview from showing up until it is in the bounds of your frame.
Upvotes: 1