@interface MyViewController ()
NSTimer *fadeTimer;
@property (nonatomic, retain) NSTimer *fadeTimer;
- (void) fadeBarController;
- (void) fadeBarAway:(NSTimer *)timer;
- (void) fadeBarIn;
@end
@implementation MyViewController
@synthesize fadeTimer;
#pragma mark -
#pragma mark View Lifecycle
-(void) viewWillAppear:(BOOL)animated {
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated: YES];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
}
- (void) viewDidAppear:(BOOL)animated {
[self fadeBarController];
}
- (void) viewDidDisappear:(BOOL)animated {
[self.fadeTimer invalidate];
}
- (void)dealloc {
[fadeTimer release];
}
#pragma mark -
#pragma mark Fade In/Out code
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
[super touchesEnded: touches withEvent: event];
[self fadeBarController];
}
- (void)fadeBarController {
if (self.navigationController.navigationBar.alpha == 0)
{
[self fadeBarIn];
}
if (self.fadeTimer != nil)
{
[self.fadeTimer invalidate];
}
self.fadeTimer = [NSTimer
scheduledTimerWithTimeInterval:kNavigationBarFadeDelay target:self
selector:@selector(fadeBarAway:) userInfo:nil repeats:NO];
}
- (void)fadeBarAway:(NSTimer*)timer {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
self.navigationController.navigationBar.alpha = 0.0;
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[UIView commitAnimations];
}
- (void)fadeBarIn {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
self.navigationController.navigationBar.alpha = 1.0;
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
[UIView commitAnimations];
}
@end
Saturday, August 29, 2009
iPhone Navigation Bar Black and Transparent!!!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment