Created
December 11, 2010 10:00
-
-
Save marshluca/737296 to your computer and use it in GitHub Desktop.
视图切换效果, slide, fade, flip
This file contains hidden or 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
- (void) fadeOut: (id) sender | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[UIView beginAnimations:nil context:context]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:1.0]; | |
[[self.view viewWithTag:999] setAlpha:0.0f]; | |
[UIView commitAnimations]; | |
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade In", @selector(fadeIn:)); | |
} | |
- (void) fadeIn: (id) sender | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[UIView beginAnimations:nil context:context]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:1.0]; | |
[[self.view viewWithTag:999] setAlpha:1.0f]; | |
[UIView commitAnimations]; | |
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade Out", @selector(fadeOut:)); | |
} |
This file contains hidden or 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
- (void) info | |
{ | |
int segment = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex]; | |
int styles[3] = { | |
UIModalTransitionStyleCoverVertical, | |
UIModalTransitionStyleCrossDissolve, | |
UIModalTransitionStyleFlipHorizontal | |
}; | |
InfoViewController *ivc = [[[InfoViewController alloc] init] autorelease]; | |
ivc.modalTransitionStyle = styles[segment]; | |
[self presentModalViewController:ivc animated:YES]; | |
} |
This file contains hidden or 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
- (void) swap: (id) sender | |
{ | |
// hide the button | |
self.navigationItem.rightBarButtonItem = nil; | |
UIView *frontObject = [[self.view subviews] objectAtIndex:2]; | |
UIView *backObject = [[self.view subviews] objectAtIndex:1]; | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[UIView beginAnimations:nil context:context]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:1.0]; | |
frontObject.alpha = 0.0f; | |
backObject.alpha = 1.0f; | |
frontObject.transform = CGAffineTransformMakeScale(0.25f, 0.25f); | |
backObject.transform = CGAffineTransformIdentity; | |
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2]; | |
[UIView setAnimationDelegate:self]; | |
[UIView setAnimationDidStopSelector:@selector(animationFinished:)]; | |
[UIView commitAnimations]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment