Merge pull request #18 from justjimmy/master

Issue #17
This commit is contained in:
Mike Enriquez
2012-10-30 07:42:28 -07:00
2 changed files with 23 additions and 4 deletions

View File

@@ -123,6 +123,14 @@ typedef enum {
*/
@property (nonatomic, unsafe_unretained) BOOL shouldAllowUserInteractionsWhenAnchored;
/** Specifies if the top view snapshot requires a pan gesture recognizer.
This is useful when panGesture is added to the navigation bar instead of the main view.
By default, this is set to NO
*/
@property (nonatomic, unsafe_unretained) BOOL shouldAddPanGestureRecognizerToTopViewSnapshot;
/** Specifies the behavior for the under left width
By default, this is set to ECFullWidth

View File

@@ -24,6 +24,7 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
@property (nonatomic, unsafe_unretained) CGFloat initialHoizontalCenter;
@property (nonatomic, strong) UIPanGestureRecognizer *panGesture;
@property (nonatomic, strong) UITapGestureRecognizer *resetTapGesture;
@property (nonatomic, strong) UIPanGestureRecognizer *topViewSnapshotPanGesture;
@property (nonatomic, unsafe_unretained) BOOL underLeftShowing;
@property (nonatomic, unsafe_unretained) BOOL underRightShowing;
@property (nonatomic, unsafe_unretained) BOOL topViewIsOffScreen;
@@ -80,6 +81,7 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
@synthesize underRightWidthLayout = _underRightWidthLayout;
@synthesize underLeftWidthLayout = _underLeftWidthLayout;
@synthesize shouldAllowUserInteractionsWhenAnchored;
@synthesize shouldAddPanGestureRecognizerToTopViewSnapshot;
@synthesize resetStrategy = _resetStrategy;
// category properties
@@ -91,6 +93,7 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
@synthesize underLeftShowing = _underLeftShowing;
@synthesize underRightShowing = _underRightShowing;
@synthesize topViewIsOffScreen = _topViewIsOffScreen;
@synthesize topViewSnapshotPanGesture = _topViewSnapshotPanGesture;
- (void)setTopViewController:(UIViewController *)theTopViewController
{
@@ -176,6 +179,7 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
{
[super viewDidLoad];
self.shouldAllowUserInteractionsWhenAnchored = NO;
self.shouldAddPanGestureRecognizerToTopViewSnapshot = NO;
self.resetTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resetTopView)];
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(updateTopViewHorizontalCenterWithRecognizer:)];
self.resetTapGesture.enabled = NO;
@@ -448,10 +452,17 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
- (void)addTopViewSnapshot
{
if (!self.topViewSnapshot.superview && !self.shouldAllowUserInteractionsWhenAnchored) {
topViewSnapshot.layer.contents = (id)[UIImage imageWithUIView:self.topView].CGImage;
[self.topView addSubview:self.topViewSnapshot];
}
if (!self.topViewSnapshot.superview && !self.shouldAllowUserInteractionsWhenAnchored) {
topViewSnapshot.layer.contents = (id)[UIImage imageWithUIView:self.topView].CGImage;
if (self.shouldAddPanGestureRecognizerToTopViewSnapshot && (_resetStrategy & ECPanning)) {
if (!_topViewSnapshotPanGesture) {
_topViewSnapshotPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(updateTopViewHorizontalCenterWithRecognizer:)];
}
[topViewSnapshot addGestureRecognizer:_topViewSnapshotPanGesture];
}
[self.topView addSubview:self.topViewSnapshot];
}
}
- (void)removeTopViewSnapshot