mirror of
https://github.com/zhigang1992/ECSlidingViewController.git
synced 2026-01-12 22:46:53 +08:00
Convenience methods for anchoring without callbacks
- Instead of calling anchorTopView:animations:onComplete: with nil blocks, you can just call anchorTopView:
This commit is contained in:
@@ -46,12 +46,12 @@
|
||||
|
||||
- (IBAction)revealMenu:(id)sender
|
||||
{
|
||||
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
|
||||
[self.slidingViewController anchorTopViewTo:ECRight];
|
||||
}
|
||||
|
||||
- (IBAction)revealUnderRight:(id)sender
|
||||
{
|
||||
[self.slidingViewController anchorTopViewTo:ECLeft animations:nil onComplete:nil];
|
||||
[self.slidingViewController anchorTopViewTo:ECLeft];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
- (IBAction)revealMenu:(id)sender
|
||||
{
|
||||
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
|
||||
[self.slidingViewController anchorTopViewTo:ECRight];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
- (IBAction)revealMenu:(id)sender
|
||||
{
|
||||
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
|
||||
[self.slidingViewController anchorTopViewTo:ECRight];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
- (IBAction)revealMenu:(id)sender
|
||||
{
|
||||
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
|
||||
[self.slidingViewController anchorTopViewTo:ECRight];
|
||||
}
|
||||
|
||||
// slidingViewController notification
|
||||
|
||||
@@ -118,6 +118,14 @@ typedef enum {
|
||||
*/
|
||||
- (UIPanGestureRecognizer *)panGesture;
|
||||
|
||||
/** Slides the top view in the direction of the specified side.
|
||||
|
||||
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
|
||||
|
||||
@param side The side for the top view to slide towards.
|
||||
*/
|
||||
- (void)anchorTopViewTo:(ECSide)side;
|
||||
|
||||
/** Slides the top view in the direction of the specified side.
|
||||
|
||||
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
|
||||
@@ -128,6 +136,12 @@ typedef enum {
|
||||
*/
|
||||
- (void)anchorTopViewTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete;
|
||||
|
||||
/** Slides the top view off of the screen in the direction of the specified side.
|
||||
|
||||
@param side The side for the top view to slide off the screen towards.
|
||||
*/
|
||||
- (void)anchorTopViewOffScreenTo:(ECSide)side;
|
||||
|
||||
/** Slides the top view off of the screen in the direction of the specified side.
|
||||
|
||||
@param side The side for the top view to slide off the screen towards.
|
||||
|
||||
@@ -185,9 +185,9 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
CGFloat currentVelocityX = currentVelocityPoint.x;
|
||||
|
||||
if ([self underLeftShowing] && currentVelocityX > 100) {
|
||||
[self anchorTopViewTo:ECRight animations:nil onComplete:nil];
|
||||
[self anchorTopViewTo:ECRight];
|
||||
} else if ([self underRightShowing] && currentVelocityX < 100) {
|
||||
[self anchorTopViewTo:ECLeft animations:nil onComplete:nil];
|
||||
[self anchorTopViewTo:ECLeft];
|
||||
} else {
|
||||
[self resetTopView];
|
||||
}
|
||||
@@ -199,6 +199,11 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
return _panGesture;
|
||||
}
|
||||
|
||||
- (void)anchorTopViewTo:(ECSide)side
|
||||
{
|
||||
[self anchorTopViewTo:side animations:nil onComplete:nil];
|
||||
}
|
||||
|
||||
- (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplete:(void (^)())complete
|
||||
{
|
||||
CGFloat newCenter = self.topView.center.x;
|
||||
@@ -234,6 +239,11 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)anchorTopViewOffScreenTo:(ECSide)side
|
||||
{
|
||||
[self anchorTopViewOffScreenTo:side animations:nil onComplete:nil];
|
||||
}
|
||||
|
||||
- (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete
|
||||
{
|
||||
CGFloat newCenter = self.topView.center.x;
|
||||
|
||||
Reference in New Issue
Block a user