mirror of
https://github.com/zhigang1992/ECSlidingViewController.git
synced 2026-03-27 22:49:37 +08:00
Added a continuous block callback to sliding
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user