Compare commits

..

2 Commits

Author SHA1 Message Date
Cezary Wojcik 18f8092416 Version 1.0.2
Updated to get status bar height programmatically
2013-10-03 23:22:09 -07:00
Cezary Wojcik 7596d2631a Updated README for CocoaPods 2013-09-19 14:30:19 -07:00
3 changed files with 15 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "A category on UIViewController to show a text notification in the status bar."
s.description = "CWStatusBarNotification adds a category on UIViewController that allows you to present a text-based notification in the status bar."
s.homepage = "http://github.com/cezarywojcik/CWStatusBarNotification"
@@ -11,7 +11,6 @@
@implementation UIViewController (CWStatusBarNotification);
#define STATUS_BAR_HEIGHT 22.0f
#define STATUS_BAR_ANIMATION_LENGTH 0.25f
#define FONT_SIZE 12.0f
@@ -44,6 +43,15 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
# pragma mark - dimensions
- (CGFloat)getStatusBarHeight {
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
}
NSLog(@"%f", statusBarHeight);
return statusBarHeight;
}
- (CGFloat)getStatusBarWidth {
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
return [UIScreen mainScreen].bounds.size.width;
@@ -52,11 +60,11 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
}
- (CGRect)getStatusBarHiddenFrame {
return CGRectMake(0, -1*STATUS_BAR_HEIGHT, [self getStatusBarWidth], STATUS_BAR_HEIGHT);
return CGRectMake(0, -1*[self getStatusBarHeight], [self getStatusBarWidth], [self getStatusBarHeight]);
}
- (CGRect)getStatusBarFrame {
return CGRectMake(0, 0, [self getStatusBarWidth], STATUS_BAR_HEIGHT);
return CGRectMake(0, 0, [self getStatusBarWidth], [self getStatusBarHeight]);
}
# pragma mark - show status bar notification function
@@ -71,10 +79,11 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
self.statusBarNotificationLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
[self.view addSubview:self.statusBarNotificationLabel];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenOrientationChanged) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
CGRect statusBarFrame = [self getStatusBarFrame];
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
self.statusBarIsHidden = YES;
[self updateStatusBar];
self.statusBarNotificationLabel.frame = [self getStatusBarFrame];
self.statusBarNotificationLabel.frame = statusBarFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:duration - 2*STATUS_BAR_ANIMATION_LENGTH animations:^{
+1 -1
View File
@@ -14,7 +14,7 @@ Works for iPhone and iPad.
### CocoaPods
*Coming Soon*
`pod 'CWStatusBarNotification', '~> 1.0.2'`
### Manual