Created
September 30, 2013 18:09
-
-
Save hfossli/6767765 to your computer and use it in GitHub Desktop.
UIApplication does not send notificaiton wether status bar is hidden or not. This class does!
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
#import <UIKit/UIKit.h> | |
extern NSString * const UIApplicationDidHideStatusBarNotification; | |
@interface IVYApplication : UIApplication | |
@end |
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
#import "IVYApplication.h" | |
NSString * const UIApplicationDidHideStatusBarNotification = @"UIApplicationDidHideStatusBarNotification"; | |
@interface IVYApplication () | |
@property (nonatomic, assign) BOOL isCheckingStatusBarDisplayChange; | |
@end | |
@implementation IVYApplication | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) | |
{ | |
} | |
return self; | |
} | |
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle | |
{ | |
[self checkForStatusBarChangeBeforeAndAfterBlock:^{ | |
[super setStatusBarStyle:statusBarStyle]; | |
}]; | |
} | |
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated | |
{ | |
[self checkForStatusBarChangeBeforeAndAfterBlock:^{ | |
[super setStatusBarStyle:statusBarStyle animated:animated]; | |
}]; | |
} | |
- (void)setStatusBarHidden:(BOOL)statusBarHidden | |
{ | |
[self checkForStatusBarChangeBeforeAndAfterBlock:^{ | |
[super setStatusBarHidden:statusBarHidden]; | |
}]; | |
} | |
- (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated | |
{ | |
[self checkForStatusBarChangeBeforeAndAfterBlock:^{ | |
[super setStatusBarHidden:hidden animated:animated]; | |
}]; | |
} | |
- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation | |
{ | |
[self checkForStatusBarChangeBeforeAndAfterBlock:^{ | |
[super setStatusBarHidden:hidden withAnimation:animation]; | |
}]; | |
} | |
- (void)checkForStatusBarChangeBeforeAndAfterBlock:(dispatch_block_t)block | |
{ | |
if(self.isCheckingStatusBarDisplayChange) | |
{ | |
return; | |
} | |
self.isCheckingStatusBarDisplayChange = YES; | |
BOOL wasHidden = self.statusBarHidden; | |
block(); | |
BOOL isHidden = self.statusBarHidden; | |
self.isCheckingStatusBarDisplayChange = NO; | |
if(wasHidden != isHidden) | |
{ | |
[self postStatusBarHideStatusNotification]; | |
} | |
} | |
- (void)postStatusBarHideStatusNotification | |
{ | |
NSNotification *notifaction = [NSNotification notificationWithName:UIApplicationDidHideStatusBarNotification object:self]; | |
[[NSNotificationCenter defaultCenter] postNotification:notifaction]; | |
} | |
@end |
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
#import <UIKit/UIKit.h> | |
#import "IVYApplication.h" | |
#import "IVYAppDelegate.h" | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool { | |
return UIApplicationMain(argc, argv, | |
NSStringFromClass([IVYApplication class]), | |
NSStringFromClass([IVYAppDelegate class])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@slangley Didn't think of that. Thanks for the feedback!