Compare commits

..

6 Commits

Author SHA1 Message Date
Cezary Wojcik 0972fa0949 1.1.0 2013-11-14 21:42:27 -08:00
Cezary Wojcik 8395fa1b96 Changed to use UIWindow 2013-11-14 21:35:05 -08:00
Cezary Wojcik 4a843c6022 Merge pull request #3 from 4ndrey/master
Removing warnings
2013-10-13 08:30:14 -07:00
Andrey Toropchin 8358c7e4a7 Removing warnings 2013-10-13 16:00:04 +06:00
Cezary Wojcik 06a4d35d82 Small fix. 2013-10-12 12:27:54 -07:00
Cezary Wojcik fa9b5635ee podspec 2013-10-03 23:38:04 -07:00
8 changed files with 32 additions and 34 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "1.0.2"
s.version = "1.1.0"
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"
s.screenshots = "https://raw.github.com/cezarywojcik/CWStatusBarNotification/master/screenshot.png"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Cezary Wojcik" => "cezarywojcik@cezarywojcik.com" }
s.author = { "Cezary Wojcik" => "me@cezarywojcik.com" }
s.platform = :ios, '6.0'
s.source = { :git => "https://github.com/cezarywojcik/CWStatusBarNotification.git",
:tag => s.version.to_s }
@@ -15,5 +15,6 @@
@property (nonatomic, readwrite) BOOL statusBarIsHidden;
@property (nonatomic, readwrite) BOOL statusBarNotificationIsShowing;
@property (nonatomic, readwrite) UILabel *statusBarNotificationLabel;
@property (nonatomic, readwrite) UIWindow *notificationWindow;
@end
@@ -17,29 +17,9 @@
NSString const *CWStatusBarIsHiddenKey = @"CWStatusBarIsHiddenKey";
NSString const *CWStatusBarNotificationIsShowingKey = @"CWStatusBarNotificationIsShowingKey";
NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabelKey";
NSString const *CWNotificationWindowKey = @"CWNotificationWindow";
# pragma mark - overriding functions
// The below functions produce warnings - not an issue
- (BOOL)prefersStatusBarHidden {
return self.statusBarIsHidden;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
return UIStatusBarAnimationSlide;
}
# pragma mark - helper functions
- (void)updateStatusBar {
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self setNeedsStatusBarAppearanceUpdate];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:self.statusBarIsHidden withAnimation:self.preferredStatusBarUpdateAnimation];
}
}
# pragma mark - dimensions
@@ -48,7 +28,6 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
}
NSLog(@"%f", statusBarHeight);
return statusBarHeight;
}
@@ -77,12 +56,20 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
self.statusBarNotificationLabel.textAlignment = NSTextAlignmentCenter;
self.statusBarNotificationLabel.adjustsFontSizeToFitWidth = YES;
self.statusBarNotificationLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
[self.view addSubview:self.statusBarNotificationLabel];
self.notificationWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.notificationWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.notificationWindow.backgroundColor = [UIColor clearColor];
self.notificationWindow.userInteractionEnabled = NO;
self.notificationWindow.windowLevel = UIWindowLevelStatusBar;
self.notificationWindow.rootViewController = [UIViewController new];
[self.notificationWindow.rootViewController.view addSubview:self.statusBarNotificationLabel];
[self.notificationWindow.rootViewController.view bringSubviewToFront:self.statusBarNotificationLabel];
[self.notificationWindow setHidden:NO];
[[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 = statusBarFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:duration - 2*STATUS_BAR_ANIMATION_LENGTH animations:^{
@@ -91,13 +78,12 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
self.statusBarIsHidden = NO;
[self updateStatusBar];
self.statusBarNotificationLabel.frame = [self getStatusBarHiddenFrame];
} completion:^(BOOL finished) {
[self.statusBarNotificationLabel removeFromSuperview];
self.notificationWindow = nil;
self.statusBarNotificationIsShowing = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}];
});
}];
@@ -136,12 +122,19 @@ NSString const *CWStatusBarNotificationLabelKey = @"CWStatusBarNotificationLabel
objc_setAssociatedObject(self, &CWStatusBarNotificationLabelKey, statusBarNotificationLabel, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (UILabel *)statusBarNotificationLabel
{
- (UILabel *)statusBarNotificationLabel {
if (objc_getAssociatedObject(self, &CWStatusBarNotificationLabelKey) == nil) {
[self setStatusBarNotificationLabel:[UILabel new]];
}
return objc_getAssociatedObject(self, &CWStatusBarNotificationLabelKey);
}
- (void)setNotificationWindow:(UIWindow *)notificationWindow {
objc_setAssociatedObject(self, &CWNotificationWindowKey, notificationWindow, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (UIWindow *)notificationWindow {
return objc_getAssociatedObject(self, &CWNotificationWindowKey);
}
@end
+3 -1
View File
@@ -21,7 +21,9 @@
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
CWSampleViewController *sampleViewController = [[CWSampleViewController alloc] initWithNibName:@"CWSampleViewController" bundle:nil];
self.window.rootViewController = sampleViewController;
UINavigationController *navigationController = [UINavigationController new];
self.window.rootViewController = navigationController;
[navigationController pushViewController:sampleViewController animated:YES];
[self.window makeKeyAndVisible];
return YES;
}
@@ -29,6 +29,7 @@
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self sliderValueChanged:nil];
self.title = @"CWStatusBarNotification";
// setup status bar notification visuals
self.statusBarNotificationLabel.textColor = [UIColor whiteColor];
self.statusBarNotificationLabel.backgroundColor = self.view.tintColor;
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 142 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 90 KiB