Added a continuous block callback to sliding

This commit is contained in:
Zachary Davison
2013-03-15 12:36:57 +00:00
parent e80b0848ac
commit 2ae2a2ba13
3 changed files with 14 additions and 0 deletions

View File

@@ -20,6 +20,10 @@
self.slidingViewController.underRightViewController = nil;
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
self.slidingViewController.continuousBlock = ^(float x){
self.view.backgroundColor = [UIColor colorWithRed:x/self.view.bounds.size.width green:50 blue:70 alpha:1];
};
}
- (IBAction)revealMenu:(id)sender

View File

@@ -159,6 +159,13 @@ typedef enum {
*/
@property (nonatomic, assign) ECResetStrategy resetStrategy;
/** Can be set to provide a continuous callback as the top view slides.
Useful for animations synchronized to the sliding.
*/
@property (nonatomic,copy) void (^continuousBlock)(float xPos);
/** Returns a horizontal panning gesture for moving the top view.
This is typically added to the top view or a top view's navigation bar.

View File

@@ -248,6 +248,9 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidRese
{
CGPoint currentTouchPoint = [recognizer locationInView:self.view];
CGFloat currentTouchPositionX = currentTouchPoint.x;
if(self.continuousBlock)
self.continuousBlock(currentTouchPositionX);
if (recognizer.state == UIGestureRecognizerStateBegan) {
self.initialTouchPositionX = currentTouchPositionX;