mirror of
https://github.com/zhigang1992/ECSlidingViewController.git
synced 2026-03-27 22:49:37 +08:00
Merge pull request #29 from thomashempel/master
Adding notifications for left or right will disappear
This commit is contained in:
@@ -15,6 +15,12 @@ extern NSString *const ECSlidingViewUnderRightWillAppear;
|
||||
/** Notification that gets posted when the underLeft view will appear */
|
||||
extern NSString *const ECSlidingViewUnderLeftWillAppear;
|
||||
|
||||
/** Notification that gets posted when the underLeft view will disappear */
|
||||
extern NSString *const ECSlidingViewUnderLeftWillDisappear;
|
||||
|
||||
/** Notification that gets posted when the underRight view will disappear */
|
||||
extern NSString *const ECSlidingViewUnderRightWillDisappear;
|
||||
|
||||
/** Notification that gets posted when the top view is anchored to the left side of the screen */
|
||||
extern NSString *const ECSlidingViewTopDidAnchorLeft;
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
|
||||
#import "ECSlidingViewController.h"
|
||||
|
||||
NSString *const ECSlidingViewUnderRightWillAppear = @"ECSlidingViewUnderRightWillAppear";
|
||||
NSString *const ECSlidingViewUnderLeftWillAppear = @"ECSlidingViewUnderLeftWillAppear";
|
||||
NSString *const ECSlidingViewTopDidAnchorLeft = @"ECSlidingViewTopDidAnchorLeft";
|
||||
NSString *const ECSlidingViewTopDidAnchorRight = @"ECSlidingViewTopDidAnchorRight";
|
||||
NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
NSString *const ECSlidingViewUnderRightWillAppear = @"ECSlidingViewUnderRightWillAppear";
|
||||
NSString *const ECSlidingViewUnderLeftWillAppear = @"ECSlidingViewUnderLeftWillAppear";
|
||||
NSString *const ECSlidingViewUnderLeftWillDisappear = @"ECSlidingViewUnderLeftWillDisappear";
|
||||
NSString *const ECSlidingViewUnderRightWillDisappear = @"ECSlidingViewUnderRightWillDisappear";
|
||||
NSString *const ECSlidingViewTopDidAnchorLeft = @"ECSlidingViewTopDidAnchorLeft";
|
||||
NSString *const ECSlidingViewTopDidAnchorRight = @"ECSlidingViewTopDidAnchorRight";
|
||||
NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
|
||||
@interface ECSlidingViewController()
|
||||
|
||||
@@ -408,8 +410,22 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
|
||||
- (void)topViewHorizontalCenterWillChange:(CGFloat)newHorizontalCenter
|
||||
{
|
||||
|
||||
|
||||
CGPoint center = self.topView.center;
|
||||
|
||||
if (center.x >= self.resettedCenter && newHorizontalCenter == self.resettedCenter) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:ECSlidingViewUnderLeftWillDisappear object:self userInfo:nil];
|
||||
});
|
||||
}
|
||||
|
||||
if (center.x <= self.resettedCenter && newHorizontalCenter == self.resettedCenter) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:ECSlidingViewUnderRightWillDisappear object:self userInfo:nil];
|
||||
});
|
||||
}
|
||||
|
||||
if (center.x <= self.resettedCenter && newHorizontalCenter > self.resettedCenter) {
|
||||
[self underLeftWillAppear];
|
||||
} else if (center.x >= self.resettedCenter && newHorizontalCenter < self.resettedCenter) {
|
||||
|
||||
Reference in New Issue
Block a user