diff --git a/NoticeView/WBNoticeView/WBErrorNoticeView.m b/NoticeView/WBNoticeView/WBErrorNoticeView.m index c344c64..b8d272c 100644 --- a/NoticeView/WBNoticeView/WBErrorNoticeView.m +++ b/NoticeView/WBNoticeView/WBErrorNoticeView.m @@ -79,7 +79,7 @@ noticeViewHeight += 30.0; // Make sure we hide completely the view, including its shadow - float hiddenYOrigin = -noticeViewHeight - 20.0; + float hiddenYOrigin = self.slidingMode == WBNoticeViewSlidingModeDown ? -noticeViewHeight - 20.0: self.view.bounds.size.height; // Make and add the notice view self.gradientView = [[WBRedGradientView alloc] initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, noticeViewHeight + 10.0)]; diff --git a/NoticeView/WBNoticeView/WBNoticeView.h b/NoticeView/WBNoticeView/WBNoticeView.h index 6208a96..2510477 100644 --- a/NoticeView/WBNoticeView/WBNoticeView.h +++ b/NoticeView/WBNoticeView/WBNoticeView.h @@ -8,6 +8,11 @@ #import +typedef enum WBNoticeViewSlidingMode { + WBNoticeViewSlidingModeUp, + WBNoticeViewSlidingModeDown, +} WBNoticeViewSlidingMode; + /** `WBNoticeView` objects provides a lightweight, non-intrusive means for displaying information to the user. The `WBNoticeView` class is an abstract class that encapsulates the interface common to all notice objects. */ @@ -91,6 +96,14 @@ */ @property (nonatomic, readwrite, getter = isSticky) BOOL sticky; +/** + Decides if the notice is shown sliding up from the bottom or down from the top + + **Default**: 'WBNoticeViewSlidingModeDown' +*/ +@property WBNoticeViewSlidingMode slidingMode; + + ///---------------------------------------- /// @name Showing and Dismissing the Notice ///---------------------------------------- diff --git a/NoticeView/WBNoticeView/WBNoticeView.m b/NoticeView/WBNoticeView/WBNoticeView.m index f2303d4..d4d3307 100644 --- a/NoticeView/WBNoticeView/WBNoticeView.m +++ b/NoticeView/WBNoticeView/WBNoticeView.m @@ -55,6 +55,7 @@ self.alpha = 1.0; self.delay = 2.0; self.tapToDismissEnabled = YES; + self.slidingMode = WBNoticeViewSlidingModeDown; } return self; } @@ -92,6 +93,11 @@ [self.gradientView addSubview:button]; } + //set default originY if WBNoticeViewSlidingModeUp + if ((self.slidingMode == WBNoticeViewSlidingModeUp) && (self.originY == 0)) { + self.originY = self.view.bounds.size.height - self.gradientView.bounds.size.height; + } + // Go ahead, display it [UIView animateWithDuration:self.duration animations:^ { CGRect newFrame = self.gradientView.frame; diff --git a/NoticeView/WBNoticeView/WBStickyNoticeView.m b/NoticeView/WBNoticeView/WBStickyNoticeView.m index 990ecfa..66b651e 100644 --- a/NoticeView/WBNoticeView/WBStickyNoticeView.m +++ b/NoticeView/WBNoticeView/WBStickyNoticeView.m @@ -50,13 +50,12 @@ // Calculate the notice view height float noticeViewHeight = 40.0; - float hiddenYOrigin = 0.0; if (numberOfLines > 1) { noticeViewHeight += (numberOfLines - 1) * messageLineHeight; } // Make sure we hide completely the view, including its shadow - hiddenYOrigin = -noticeViewHeight - 20.0; + float hiddenYOrigin = self.slidingMode == WBNoticeViewSlidingModeDown ? -noticeViewHeight - 20.0: self.view.bounds.size.height; // Make and add the notice view self.gradientView = [[WBGrayGradientView alloc] initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, 32)]; diff --git a/NoticeView/WBNoticeView/WBSuccessNoticeView.m b/NoticeView/WBNoticeView/WBSuccessNoticeView.m index 7a8f421..1c45d49 100644 --- a/NoticeView/WBNoticeView/WBSuccessNoticeView.m +++ b/NoticeView/WBNoticeView/WBSuccessNoticeView.m @@ -45,13 +45,12 @@ // Calculate the notice view height float noticeViewHeight = 40.0; - float hiddenYOrigin = 0.0; if (numberOfLines > 1) { noticeViewHeight += (numberOfLines - 1) * messageLineHeight; } // Make sure we hide completely the view, including its shadow - hiddenYOrigin = -noticeViewHeight - 20.0; + float hiddenYOrigin = self.slidingMode == WBNoticeViewSlidingModeDown ? -noticeViewHeight - 20.0: self.view.bounds.size.height; // Make and add the notice view self.gradientView = [[WBBlueGradientView alloc] initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, noticeViewHeight + 10.0)];