Skip to content
Browse files

Modified manual hiding example.

  • Loading branch information...
1 parent b9f3d4c commit 7311415ff362d3ea657391d6e38f762fd74f511f @frankdilo committed
Showing with 15 additions and 6 deletions.
  1. +3 −3 FDStatusBarNotifierView/FDStatusBarNotifierView.m
  2. +11 −2 README.md
  3. +1 −1 SampleProject/Example/ViewController.m
View
6 FDStatusBarNotifierView/FDStatusBarNotifierView.m
@@ -8,7 +8,6 @@
#import "FDStatusBarNotifierView.h"
-NSTimeInterval const kTimeOnScreenManuallyHide = 0.0;
NSTimeInterval const kTimeOnScreenDefault = 2.0;
@interface FDStatusBarNotifierView ()
@@ -36,6 +35,7 @@ - (id)init
self.messageLabel.textAlignment = UITextAlignmentCenter;
self.messageLabel.font = [UIFont boldSystemFontOfSize:12];
self.shouldHideOnTap = NO;
+ self.manuallyHide = NO;
[self addSubview:self.messageLabel];
self.timeOnScreen = kTimeOnScreenDefault;
@@ -97,7 +97,7 @@ - (void)showInWindow:(UIWindow *)window
[self.delegate didPresentNotifierView:self];
}
- if (self.timeOnScreen != kTimeOnScreenManuallyHide) {
+ if (!self.manuallyHide) {
[NSTimer scheduledTimerWithTimeInterval:self.timeOnScreen
target:self
selector:@selector(hide)
@@ -121,7 +121,7 @@ - (void)showInWindow:(UIWindow *)window
if (self.delegate && [self.delegate respondsToSelector:@selector(didPresentNotifierView:)])
[self.delegate didPresentNotifierView:self];
- if (self.timeOnScreen != kTimeOnScreenManuallyHide) {
+ if (!self.manuallyHide) {
[self performSelector:@selector(hide)
withObject:nil
afterDelay:self.timeOnScreen + timeExceed];
View
13 README.md
@@ -26,7 +26,16 @@ When you call `showInWindow:` the status bar disappear and the notifier view tak
## Manually hide
-If can specify a `timeOnScreen` that automatically hide the notifier. You also have the ability to manualy hide it (e.g., in case of you use it for network activity), to do so you have to set the `timeOnScreen = kTimeOnScreenManuallyHide` and when your done you call `- hide:`.
+In some circumstances (e.g., informing the user of network activities), you may want to manually hide the component.
+
+To do so just set the `manuallyHide` property to `YES`. Then hide calling the `hide` method.
+
+ notifierView.manuallyHide = YES;
+
+ // do some stuff
+
+ [notifierView hide];
+
## More
@@ -51,7 +60,7 @@ Feel free to help out by sending pull requests or by creating new issues.
## Contributors
- [ZachOrr](https://github.com/ZachOrr): iPad support, hide on tap, better handling of device’s screen sizes.
- [dbsGen](https://github.com/dbsGen): if the message to display doesn’t fit in the status bar, it will scroll horizontally.
-- [Luca Bernardi](https://github.com/lukabernardi): CocoaPods support.
+- [Luca Bernardi](https://github.com/lukabernardi): CocoaPods support, manual hiding.
## TO DO
View
2 SampleProject/Example/ViewController.m
@@ -49,7 +49,7 @@ - (IBAction)showMessageNoAutohide:(id)sender {
NSString *text = self.messageField.text;
_notifierView = [[FDStatusBarNotifierView alloc] initWithMessage:text delegate:self];
- _notifierView.timeOnScreen = kTimeOnScreenManuallyHide;
+ _notifierView.manuallyHide = YES;
[_notifierView showInWindow:self.view.window];
}

0 comments on commit 7311415

Please sign in to comment.
Something went wrong with that request. Please try again.