forked from John-Lluch/SWRevealViewController
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joan Lluch
committed
Mar 9, 2014
1 parent
20f8383
commit b669863
Showing
17 changed files
with
553 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
Early code inspired on a similar class by Philip Kluz ([email protected]) | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
/* | ||
Copyright (c) 2011, Philip Kluz ([email protected]) | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
/* | ||
Copyright (c) 2013 Joan Lluch <[email protected]> | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
* Neither the name of Philip Kluz, 'zuui.org' nor the names of its contributors may | ||
be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL PHILIP KLUZ BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
Early code inspired on a similar class by Philip Kluz ([email protected]) | ||
*/ | ||
*/ | ||
|
||
|
||
#import "AppDelegate.h" | ||
|
||
#import "SWRevealViewController.h" | ||
#import "FrontViewController.h" | ||
#import "RearViewController.h" | ||
#import "RightViewController.h" | ||
#import "CustomAnimationController.h" | ||
|
||
@interface AppDelegate()<SWRevealViewControllerDelegate> | ||
@end | ||
|
@@ -75,7 +71,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( | |
return YES; | ||
} | ||
|
||
#define LogDelegates 1 | ||
#pragma mark - SWRevealViewDelegate | ||
|
||
- (id <UIViewControllerAnimatedTransitioning>)revealController:(SWRevealViewController *)revealController animationControllerForOperation:(SWRevealControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC | ||
{ | ||
if ( operation != SWRevealControllerOperationReplaceRightController ) | ||
return nil; | ||
|
||
if ( [toVC isKindOfClass:[RightViewController class]] ) | ||
{ | ||
if ( [(RightViewController*)toVC wantsCustomAnimation] ) | ||
{ | ||
id<UIViewControllerAnimatedTransitioning> animationController = [[CustomAnimationController alloc] init]; | ||
return animationController; | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
|
||
#define LogDelegates 0 | ||
|
||
#if LogDelegates | ||
- (NSString*)stringFromFrontViewPosition:(FrontViewPosition)position | ||
|
@@ -91,7 +107,6 @@ - (NSString*)stringFromFrontViewPosition:(FrontViewPosition)position | |
return str; | ||
} | ||
|
||
|
||
- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position | ||
{ | ||
NSLog( @"%@: %@", NSStringFromSelector(_cmd), [self stringFromFrontViewPosition:position]); | ||
|
29 changes: 29 additions & 0 deletions
29
RevealControllerExample/RevealControllerProject/CustomAnimationController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright (c) 2013 Joan Lluch <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface CustomAnimationController : NSObject<UIViewControllerAnimatedTransitioning> | ||
|
||
@end |
62 changes: 62 additions & 0 deletions
62
RevealControllerExample/RevealControllerProject/CustomAnimationController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Copyright (c) 2013 Joan Lluch <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
#import "CustomAnimationController.h" | ||
|
||
|
||
#define TRANSITION_DURATION 0.5 | ||
|
||
@implementation CustomAnimationController | ||
|
||
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext | ||
{ | ||
return TRANSITION_DURATION; | ||
} | ||
|
||
|
||
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext | ||
{ | ||
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | ||
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | ||
|
||
UIView *fromView = fromViewController.view; | ||
UIView *toView = toViewController.view; | ||
|
||
CGRect initialFromViewFrame = [transitionContext initialFrameForViewController:fromViewController]; | ||
CGRect finalFromViewFrame = initialFromViewFrame; | ||
finalFromViewFrame.origin.y -= initialFromViewFrame.size.height; | ||
|
||
CGRect finalToViewFrame = [transitionContext finalFrameForViewController:toViewController]; | ||
CGRect initialToViewFrame = finalToViewFrame; | ||
initialToViewFrame.origin.y += finalToViewFrame.size.height; | ||
|
||
fromView.frame = initialFromViewFrame; | ||
toView.frame = initialToViewFrame; | ||
|
||
[UIView animateWithDuration:TRANSITION_DURATION | ||
animations:^ { fromView.frame = finalFromViewFrame; toView.frame = finalToViewFrame;} | ||
completion:^(BOOL finished) { [transitionContext completeTransition:finished]; }]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,6 @@ | |
|
||
@interface RightViewController : UIViewController | ||
|
||
@property (nonatomic) BOOL wantsCustomAnimation; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.