- - (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:));
- }
- - (void) viewDidLoad {
- self.navigationItem.rightBarButtonItem = BARBUTTON(@”Fade Out”,@selector(fadeOut:));
- }
- @end
来源: http://www.phpxs.com/code/1005423/