From c90384b88e19460cc2d4ef52fdfc56323df9efca Mon Sep 17 00:00:00 2001 From: Alex Wait Date: Tue, 6 Aug 2013 17:24:40 -0700 Subject: [PATCH] Adding boolean that represents if the notice is currently "seen" on the screen. Useful for checking against to prevent multiple notices from appearing. --- NoticeView/WBNoticeView/WBNoticeView.h | 8 ++++++++ NoticeView/WBNoticeView/WBNoticeView.m | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NoticeView/WBNoticeView/WBNoticeView.h b/NoticeView/WBNoticeView/WBNoticeView.h index 8537b4f..62b1bf5 100644 --- a/NoticeView/WBNoticeView/WBNoticeView.h +++ b/NoticeView/WBNoticeView/WBNoticeView.h @@ -116,6 +116,14 @@ typedef enum WBNoticeViewSlidingMode { */ @property (nonatomic, readwrite, getter = isFloating) BOOL floating; +/** +* +* A boolean value that represents whether or not the current notice view is visible on screen or not. +* Easy way to prevent multiple notices being shown at once is to check this property. :) +* +*/ +@property(nonatomic, readonly) BOOL currentlyDisplayed; + ///---------------------------------------- /// @name Showing and Dismissing the Notice ///---------------------------------------- diff --git a/NoticeView/WBNoticeView/WBNoticeView.m b/NoticeView/WBNoticeView/WBNoticeView.m index 2dec11d..10d68ba 100644 --- a/NoticeView/WBNoticeView/WBNoticeView.m +++ b/NoticeView/WBNoticeView/WBNoticeView.m @@ -47,6 +47,7 @@ @implementation WBNoticeView @synthesize dismissalBlock = _dismissalBlock; @synthesize dismissalBlockWithOptionalDismiss = _dismissalBlockWithOptionalDismiss; @synthesize floating = _floating; +@synthesize currentlyDisplayed = _currentlyDisplayed; - (id)initWithView:(UIView *)view title:(NSString *)title { @@ -62,6 +63,7 @@ - (id)initWithView:(UIView *)view title:(NSString *)title _tapToDismissEnabled = YES; _slidingMode = WBNoticeViewSlidingModeDown; _floating = NO; + _currentlyDisplayed = NO; _contentInset = UIEdgeInsetsMake(0,0,0,0); // No insets as default } return self; @@ -104,7 +106,9 @@ - (void)displayNotice { self.gradientView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth; } - + + _currentlyDisplayed = YES; + // Go ahead, display it [UIView animateWithDuration:self.duration animations:^ { CGRect newFrame = self.gradientView.frame; @@ -152,7 +156,7 @@ - (void)dismissNoticeWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval BOOL dismissAfterBlock = YES; self.dismissalBlockWithOptionalDismiss(NO, &dismissAfterBlock); } - + _currentlyDisplayed = NO; // Cleanup [self cleanup]; }];