Skip to content

Instantly share code, notes, and snippets.

@dcastro
Created May 30, 2012 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcastro/2835703 to your computer and use it in GitHub Desktop.
Save dcastro/2835703 to your computer and use it in GitHub Desktop.
iOS 3 types of crossfade animations
[UIView animateWithDuration:0.3 animations:^() {
self.commentContentLabel.alpha = (editing)? 0.0 : 1.0;
}];
////////////////
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.commentContentLabel cache:YES];
self.commentContentLabel.hidden = editing;
[UIView commitAnimations];
///////////////////
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionTransitionCrossDissolve;
[UIView transitionWithView:self.bottomScrollView
duration:0.3
options:options
animations:^{
self.commentContentLabel.hidden = editing;
self.commentContentTextView.hidden = !editing;
}
completion:NULL];
//////// CORE ANIMATION
#import <QuartzCore/QuartzCore.h>
CATransition *transition = [CATransition animation];
transition.duration = 0.8;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[[[[[self view] subviews] objectAtIndex:0] layer] addAnimation:transition forKey:nil];
[currentVC viewWillAppear:YES];
[destinationVC viewWillDisappear:YES];
[destinationVC viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment