Created
November 11, 2010 03:00
-
-
Save alanjrogers/671918 to your computer and use it in GitHub Desktop.
Sample code showing how to add a CATransition to changing the image on a UIImageView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImage* newImage = [UIImage imageNamed:context]; | |
// set up an animation for the transition the content | |
CATransition *animation = [CATransition animation]; | |
[animation setDuration:0.25]; | |
[animation setType:kCATransitionPush]; | |
[animation setSubtype:kCATransitionFromRight]; | |
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; | |
[[self.contentImageView layer] addAnimation:animation forKey:@"SwitchToView1"]; | |
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:0.25]; | |
self.contentImageView.image = newImage; | |
[UIView commitAnimations]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment