-
Notifications
You must be signed in to change notification settings - Fork 108
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
Showing
17 changed files
with
375 additions
and
173 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
Binary file modified
BIN
+4.05 KB
(110%)
...codeproj/project.xcworkspace/xcuserdata/dw_ios.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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
15 changes: 15 additions & 0 deletions
15
PinterestAnimator/Helpers/NavigationHelper/Transition/XHPinterestPopTransition.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,15 @@ | ||
// | ||
// XHPinterestPopTransition.h | ||
// PinterestExample | ||
// | ||
// Created by dw_iOS on 14-8-14. | ||
// Copyright (c) 2014年 广州华多网络科技有限公司 多玩事业部 iOS软件工程师 曾宪华. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "XHPinterestTransition.h" | ||
|
||
@interface XHPinterestPopTransition : XHPinterestTransition | ||
|
||
@end |
92 changes: 92 additions & 0 deletions
92
PinterestAnimator/Helpers/NavigationHelper/Transition/XHPinterestPopTransition.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,92 @@ | ||
// | ||
// XHPinterestPopTransition.m | ||
// PinterestExample | ||
// | ||
// Created by dw_iOS on 14-8-14. | ||
// Copyright (c) 2014年 广州华多网络科技有限公司 多玩事业部 iOS软件工程师 曾宪华. All rights reserved. | ||
// | ||
|
||
#import "XHPinterestPopTransition.h" | ||
|
||
@implementation XHPinterestPopTransition | ||
|
||
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { | ||
|
||
UIViewController <XHTransitionProtocol> *fromViewController = (UIViewController <XHTransitionProtocol> * )([transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]); | ||
|
||
UIViewController <XHTransitionProtocol> *toViewController = (UIViewController <XHTransitionProtocol> * )([transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]); | ||
|
||
UIView *containerView = [transitionContext containerView]; | ||
|
||
UIView *toView = toViewController.view; | ||
|
||
[containerView addSubview:toView]; | ||
toView.hidden = YES; | ||
|
||
UICollectionView *waterFallView = [toViewController transitionCollectionView]; | ||
|
||
UICollectionView *pageView = [fromViewController transitionCollectionView]; | ||
|
||
|
||
[waterFallView layoutIfNeeded]; | ||
|
||
NSIndexPath *indexPath = pageView.currentIndexPath; | ||
|
||
UIView <XHTansitionWaterfallGridViewProtocol> *gridView = (UIView <XHTansitionWaterfallGridViewProtocol> *)([waterFallView cellForItemAtIndexPath:indexPath]); | ||
|
||
[waterFallView performBatchUpdates:^{ | ||
|
||
} completion:NULL]; | ||
|
||
|
||
CGPoint leftUpperPoint = [gridView convertPoint:CGPointZero toView:nil]; | ||
|
||
UIView *snapShot = [gridView snapShotForTransition]; | ||
|
||
CGFloat animationScale = [self animationScale]; | ||
|
||
snapShot.transform = CGAffineTransformMakeScale(animationScale, animationScale); | ||
|
||
CGFloat pullOffsetY = [(UIViewController <XHHorizontalPageViewControllerProtocol> *)fromViewController pageViewCellScrollViewContentOffset].y; | ||
|
||
CGFloat offsetY = fromViewController.navigationController.navigationBarHidden ? 0.0 : 64; | ||
[snapShot setOrigin:CGPointMake(kXHLargeGridItemPadding, -pullOffsetY+offsetY + kXHLargeGridItemPadding)]; | ||
|
||
[containerView addSubview:snapShot]; | ||
|
||
|
||
toView.hidden = NO; | ||
|
||
toView.alpha = 0.0; | ||
toView.transform = snapShot.transform; | ||
|
||
toView.frame = CGRectMake(-(leftUpperPoint.x * animationScale), -((leftUpperPoint.y-offsetY) * animationScale + pullOffsetY+offsetY), | ||
toView.frame.size.width, toView.frame.size.height); | ||
|
||
|
||
UIView *whiteViewContainer = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
|
||
whiteViewContainer.backgroundColor = [UIColor whiteColor]; | ||
|
||
[containerView addSubview:whiteViewContainer]; | ||
[containerView insertSubview:whiteViewContainer belowSubview:toView]; | ||
|
||
[UIView animateWithDuration:[self animationDuration] animations:^{ | ||
snapShot.transform = CGAffineTransformIdentity; | ||
[snapShot setOrigin:leftUpperPoint]; | ||
|
||
toView.transform = CGAffineTransformIdentity; | ||
[toView setOrigin:CGPointZero]; | ||
toView.alpha = 1.0; | ||
|
||
} completion:^(BOOL finished) { | ||
if (finished) { | ||
[snapShot removeFromSuperview]; | ||
[whiteViewContainer removeFromSuperview]; | ||
[transitionContext completeTransition:!self.canceled]; | ||
} | ||
|
||
}]; | ||
} | ||
|
||
@end |
15 changes: 15 additions & 0 deletions
15
PinterestAnimator/Helpers/NavigationHelper/Transition/XHPinterestPushTransition.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,15 @@ | ||
// | ||
// XHPinterestPushTransition.h | ||
// PinterestExample | ||
// | ||
// Created by dw_iOS on 14-8-14. | ||
// Copyright (c) 2014年 广州华多网络科技有限公司 多玩事业部 iOS软件工程师 曾宪华. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "XHPinterestTransition.h" | ||
|
||
@interface XHPinterestPushTransition : XHPinterestTransition | ||
|
||
@end |
76 changes: 76 additions & 0 deletions
76
PinterestAnimator/Helpers/NavigationHelper/Transition/XHPinterestPushTransition.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,76 @@ | ||
// | ||
// XHPinterestPushTransition.m | ||
// PinterestExample | ||
// | ||
// Created by dw_iOS on 14-8-14. | ||
// Copyright (c) 2014年 广州华多网络科技有限公司 多玩事业部 iOS软件工程师 曾宪华. All rights reserved. | ||
// | ||
|
||
#import "XHPinterestPushTransition.h" | ||
|
||
@implementation XHPinterestPushTransition | ||
|
||
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { | ||
|
||
UIViewController <XHTransitionProtocol> *fromViewController = (UIViewController <XHTransitionProtocol> * )([transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]); | ||
|
||
UIViewController <XHTransitionProtocol> *toViewController = (UIViewController <XHTransitionProtocol> * )([transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]); | ||
|
||
UIView *containerView = [transitionContext containerView]; | ||
|
||
UIView *fromView = fromViewController.view; | ||
UIView *toView = toViewController.view; | ||
|
||
UICollectionView *waterFallView = [fromViewController transitionCollectionView]; | ||
|
||
UICollectionView *pageView = [toViewController transitionCollectionView]; | ||
|
||
[containerView addSubview:fromView]; | ||
[containerView addSubview:toView]; | ||
|
||
NSIndexPath *indexPath = [waterFallView currentIndexPath]; | ||
|
||
UIView <XHTansitionWaterfallGridViewProtocol> *gridView = (UIView <XHTansitionWaterfallGridViewProtocol> *)([waterFallView cellForItemAtIndexPath:indexPath]); | ||
|
||
CGPoint leftUpperPoint = [gridView convertPoint:CGPointZero toView:nil]; | ||
|
||
pageView.hidden = YES; | ||
|
||
[pageView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO]; | ||
|
||
CGFloat offsetY = fromViewController.navigationController.navigationBarHidden ? 0.0 : 64; | ||
|
||
|
||
CGFloat offsetStatuBar = fromViewController.navigationController.navigationBarHidden ? 0.0 : 64; | ||
|
||
UIView *snapShot = [gridView snapShotForTransition]; | ||
[containerView addSubview:snapShot]; | ||
[snapShot setOrigin:leftUpperPoint]; | ||
|
||
CGFloat animationScale = [self animationScale]; | ||
[UIView animateWithDuration:[self animationDuration] animations:^{ | ||
|
||
snapShot.transform = CGAffineTransformMakeScale(animationScale, | ||
animationScale); | ||
|
||
[snapShot setOrigin:CGPointMake(kXHLargeGridItemPadding, offsetY + kXHLargeGridItemPadding)]; | ||
|
||
fromView.alpha = 0; | ||
fromView.transform = snapShot.transform; | ||
fromView.frame = CGRectMake(-(leftUpperPoint.x)*animationScale, | ||
-(leftUpperPoint.y-offsetStatuBar)*animationScale+offsetStatuBar, | ||
fromView.frame.size.width, | ||
fromView.frame.size.height); | ||
|
||
} completion:^(BOOL finished) { | ||
if (finished) { | ||
[snapShot removeFromSuperview]; | ||
pageView.hidden = NO; | ||
fromView.transform = CGAffineTransformIdentity; | ||
[transitionContext completeTransition:!self.canceled]; | ||
} | ||
}]; | ||
} | ||
|
||
|
||
@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.