├── .gitignore
├── .swift-version
├── LICENSE.txt
├── README.md
├── WXSTransition.podspec
├── WXSTransition.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── wangxiaoshu.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── WXSTransition.xcscheme
│ └── xcschememanagement.plist
├── WXSTransition
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Contents.json
│ ├── bg0.imageset
│ │ ├── Contents.json
│ │ └── bg.png
│ ├── bg1.imageset
│ │ ├── Contents.json
│ │ └── bg1.png
│ ├── bg2.imageset
│ │ ├── Contents.json
│ │ └── bg2.png
│ ├── bg3.imageset
│ │ ├── Contents.json
│ │ └── bg3.png
│ ├── bg4.imageset
│ │ ├── Contents.json
│ │ └── bg4.png
│ ├── img.imageset
│ │ ├── Contents.json
│ │ └── img.png
│ └── start.imageset
│ │ ├── Contents.json
│ │ ├── collectCourse@2x.png
│ │ └── collectCourse@3x.png
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── CollectionViewCell.h
├── CollectionViewCell.m
├── CollectionViewController.h
├── CollectionViewController.m
├── DetailViewController.h
├── DetailViewController.m
├── Info.plist
├── PageTransition.h
├── PageTransition.m
├── PresentViewController.h
├── PresentViewController.m
├── SecondViewController.h
├── SecondViewController.m
├── TableViewController.h
├── TableViewController.m
├── ViewController.h
├── ViewController.m
├── WXSBaseViewController.h
├── WXSBaseViewController.m
├── WXSTestViewController.h
├── WXSTestViewController.m
├── WXSTransition
│ ├── UINavigationController+WXSTransition.h
│ ├── UINavigationController+WXSTransition.m
│ ├── UIViewController+WXSTransition.h
│ ├── UIViewController+WXSTransition.m
│ ├── UIViewController+WXSTransitionProperty.h
│ ├── UIViewController+WXSTransitionProperty.m
│ ├── WXSPercentDrivenInteractiveTransition.h
│ ├── WXSPercentDrivenInteractiveTransition.m
│ ├── WXSTransitionManager+BoomAnimation.h
│ ├── WXSTransitionManager+BoomAnimation.m
│ ├── WXSTransitionManager+BrickAnimation.h
│ ├── WXSTransitionManager+BrickAnimation.m
│ ├── WXSTransitionManager+CoverAnimation.h
│ ├── WXSTransitionManager+CoverAnimation.m
│ ├── WXSTransitionManager+FlipAnimation.h
│ ├── WXSTransitionManager+FlipAnimation.m
│ ├── WXSTransitionManager+FragmentAnimation.h
│ ├── WXSTransitionManager+FragmentAnimation.m
│ ├── WXSTransitionManager+InsideThenPushAnimation.h
│ ├── WXSTransitionManager+InsideThenPushAnimation.m
│ ├── WXSTransitionManager+PageAnimation.h
│ ├── WXSTransitionManager+PageAnimation.m
│ ├── WXSTransitionManager+SpreadAnimation.h
│ ├── WXSTransitionManager+SpreadAnimation.m
│ ├── WXSTransitionManager+SystermAnimation.h
│ ├── WXSTransitionManager+SystermAnimation.m
│ ├── WXSTransitionManager+TypeTool.h
│ ├── WXSTransitionManager+TypeTool.m
│ ├── WXSTransitionManager+ViewMoveAnimation.h
│ ├── WXSTransitionManager+ViewMoveAnimation.m
│ ├── WXSTransitionManager.h
│ ├── WXSTransitionManager.m
│ ├── WXSTransitionProperty.h
│ ├── WXSTransitionProperty.m
│ └── WXSTypedefConfig.h
└── main.m
├── WXSTransitionTests
├── Info.plist
└── WXSTransitionTests.m
├── WXSTransitionUITests
├── Info.plist
└── WXSTransitionUITests.m
└── gif
├── boom.gif
├── brick_close_H.gif
├── brick_open_V.gif
├── cover.gif
├── flip.gif
├── fragmentFromTop.gif
├── frgmentFromRight.gif
├── gestureSpread.gif
├── insideThenPush.gif
├── normalViewMove.gif
├── point_spread.gif
├── spread_from_right.gif
├── spread_from_top.gif
├── sys_oglFlip.gif
├── sys_pageCurl.gif
└── view_move_next.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | tignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
2 |
3 | ## Build generated
4 | build/
5 | DerivedData
6 |
7 | ## Various settings
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 |
18 | ## Other
19 | *.xccheckout
20 | *.moved-aside
21 | *.xcuserstate
22 | *.xcscmblueprint
23 | *.xcscheme
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 |
29 | # CocoaPods
30 | #
31 | # We recommend against adding the Pods directory to your .gitignore. However
32 | # you should judge for yourself, the pros and cons are mentioned at:
33 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
34 | #
35 | # Pods/
36 |
37 | # Carthage
38 | #
39 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
40 | # Carthage/Checkouts
41 |
42 | Carthage/Build
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
50 |
51 | fastlane/report.xml
52 | fastlane/screenshots
53 |
--------------------------------------------------------------------------------
/.swift-version:
--------------------------------------------------------------------------------
1 | 2.3
2 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 王小树
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WXSTransition
2 |
3 | ### 介绍(Introduce)
4 | It is a transition animation asset。
5 | We can add some transiton animations between view controllers in our iOS Apps .
6 | Now,it is easily to do this by this animation asset,even only one line of code.
7 | It includes about 50 kinds of animations.
8 | Now, it support 4 kinds of gesture for pop view controller. You can see the property in ```WXSTransitionProperty```
9 |
10 |
11 | 这是一个界面转场动画集。
12 | 目前只支持纯代码。
13 | 在平时开发中,有时候需要一些转场动画给界面调整增添一些活力,而实现这些动画相对比较繁琐。为了让实现转场更简单,我写了这个界面转场动画集。跳转界面时,只要一行代码就可以实现这里面的动画。包括系统提供的动画在内,目前有大概50种动画。
14 |
15 | 现在已支持手势返回,有四个手势可以选择,可以在```WXSTransitionProperty```查看相关相关属性
16 |
17 | ### 使用方法(Usage)
18 | ##### 1、首先导入头文件
19 | ```#import "UINavigationController+WXSTransition.h"```
20 |
21 | ##### 2、一行代码就可以调用
22 | Push:
23 | ```
24 | [self.navigationController wxs_pushViewController:(UIViewController *) animationType:(WXSTransitionAnimationType)];
25 | ```
26 | Present:
27 |
28 | ```
29 | [self wxs_presentViewController:(UIViewController *) animationType:(WXSTransitionAnimationType) completion:^{
30 |
31 | }];
32 | ```
33 | 说明:
34 | WXSTransitionAnimationType是转场动画类型,通过这个枚举选择你想要的转场动画。
35 |
36 | ##### 3、支持属性修改(Custom made property)
37 |
38 | ```
39 | [self wxs_presentViewController:<#(UIViewController *)#> makeTransition:^(WXSTransitionManager *transition) {
40 | transition.animationType = WXSTransitionAnimationTypePointSpreadPresent;
41 | transition.animationTime = 1;
42 | }];
43 | ```
44 | 可以通过transition设置动画时间、、返回手势、动画类型等属性,可以在```WXSTransitionProperty```查看相关可修改属性。
45 |
46 |
47 | 像point Spread 、ViewMoveToNextVC这样的动画,需要个起始view,只要将目标控制器的startView指向这个view就可以了,代码如下;
48 | 
49 |
50 | ```
51 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
52 | transition.animationType = WXSTransitionAnimationTypeViewMoveToNextVC;
53 | transition.animationTime = 1;
54 | transition.startView = cell.imgView;
55 | transition.targetView = vc.imageView;
56 | }];
57 |
58 | ```
59 |
60 | ### 动画效果图
61 |
62 | ##### 自定义动画
63 |
64 | boom:
65 | 
66 |
67 | brick:
68 | 
69 | 
70 |
71 | cover:
72 | 
73 |
74 | spread:
75 | 
76 | 
77 | 
78 |
79 |
80 | view move:
81 | 
82 | 
83 |
84 | frgment:
85 | 
86 | 
87 |
88 |
89 | insideThenPush:
90 | 
91 |
92 | ######系统动画
93 | iOS自身其实有许多不错的转场动画,在这个转场动画集里也进行了封装,使用方法跟自定义转场动画一样。
94 |
95 | Push:
96 | ```
97 | [self.navigationController wxs_pushViewController:<#(UIViewController *)#> animationType:<#(WXSTransitionAnimationType)#>];
98 | ```
99 | Present:
100 |
101 | ```
102 | [self wxs_presentViewController:<#(UIViewController *)#> animationType:<#(WXSTransitionAnimationType)#> completion:<#^(void)completion#>]
103 | ```
104 |
105 | 
106 | 
107 |
108 |
109 |
110 |
111 | # 关于tabbar动画影响效果的问题:
112 | 如果tabbar的系统动画影响了效果,可以用一下方法去掉动画。
113 | 把 self.hidesBottomBarWhenPushed = YES 去掉
114 | 手动控制tabbar的隐藏显示时机:
115 | push之前把tabBar隐藏
116 | self.tabBarController.tabBar.hidden = YES;
117 | pop后在viewDidApear里显示
118 | self.tabBarController.tabBar.hidden = NO;
119 |
120 |
--------------------------------------------------------------------------------
/WXSTransition.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'WXSTransition'
3 | s.summary = 'A library for transition animations between view controlles.'
4 | s.version = '1.2.1'
5 | s.license = "MIT"
6 | s.authors = { 'alanwangmodify' => 'alanwangmodify@126.com' }
7 | s.homepage = 'https://github.com/alanwangmodify/WXSTransition'
8 |
9 | s.ios.deployment_target = '7.0'
10 |
11 | s.source = { :git => 'https://github.com/alanwangmodify/WXSTransition.git', :tag => s.version.to_s }
12 |
13 | s.requires_arc = true
14 | s.source_files = 'WXSTransition/WXSTransition/*.{h,m}'
15 |
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/WXSTransition.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WXSTransition.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
18 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WXSTransition.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcschemes/WXSTransition.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/WXSTransition.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | WXSTransition.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 925707981CFC1E87004EB63C
16 |
17 | primary
18 |
19 |
20 | 925707B11CFC1E87004EB63C
21 |
22 | primary
23 |
24 |
25 | 925707BC1CFC1E87004EB63C
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/WXSTransition/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/WXSTransition/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | }
88 | ],
89 | "info" : {
90 | "version" : 1,
91 | "author" : "xcode"
92 | }
93 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg0.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "bg.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg0.imageset/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/bg0.imageset/bg.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "bg1.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg1.imageset/bg1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/bg1.imageset/bg1.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "bg2.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg2.imageset/bg2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/bg2.imageset/bg2.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "bg3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg3.imageset/bg3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/bg3.imageset/bg3.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "bg4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/bg4.imageset/bg4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/bg4.imageset/bg4.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/img.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "img.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/img.imageset/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/img.imageset/img.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/start.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "collectCourse@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "collectCourse@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/start.imageset/collectCourse@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/start.imageset/collectCourse@2x.png
--------------------------------------------------------------------------------
/WXSTransition/Assets.xcassets/start.imageset/collectCourse@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/WXSTransition/Assets.xcassets/start.imageset/collectCourse@3x.png
--------------------------------------------------------------------------------
/WXSTransition/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WXSTransition/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/WXSTransition/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | @property (nonatomic,strong) UIImageView *imgView;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | @implementation CollectionViewCell
12 |
13 | -(instancetype)initWithFrame:(CGRect)frame{
14 | self = [super initWithFrame:frame];
15 | if (self) {
16 | [self.contentView addSubview:self.imgView];
17 | }
18 | return self;
19 |
20 | }
21 |
22 | -(UIImageView *)imgView {
23 | if (!_imgView) {
24 | _imgView = [[UIImageView alloc] initWithFrame:self.bounds];
25 | _imgView.image = [UIImage imageNamed:@"img"];
26 |
27 | }
28 | return _imgView;
29 | }
30 | @end
31 |
--------------------------------------------------------------------------------
/WXSTransition/CollectionViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WXSBaseViewController.h"
11 |
12 | @interface CollectionViewController : WXSBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/WXSTransition/CollectionViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewController.h"
10 | #import "CollectionViewCell.h"
11 | #import "DetailViewController.h"
12 | #import "UINavigationController+WXSTransition.h"
13 | @interface CollectionViewController ()
14 | @property (nonatomic,strong) UICollectionView *collectionView;
15 |
16 | @end
17 |
18 | @implementation CollectionViewController
19 |
20 | static NSString *identifier = @"identifier";
21 |
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 | self.view.backgroundColor = [UIColor whiteColor];
26 | [self.view addSubview:self.collectionView];
27 | [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:identifier];
28 | }
29 | -(void)viewWillAppear:(BOOL)animated{
30 | [super viewWillAppear:animated];
31 | }
32 | - (void)viewDidAppear:(BOOL)animated {
33 | [super viewDidAppear:animated];
34 | }
35 | #pragma mark Delegate
36 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
37 | return 10;
38 | }
39 |
40 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
41 | CollectionViewCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
42 | return cell;
43 | }
44 |
45 | -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
46 |
47 | DetailViewController *vc = [[DetailViewController alloc] init];
48 | __weak CollectionViewCell *cell = (CollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
49 | __weak DetailViewController *weakVC = vc;
50 |
51 | if (indexPath.row % 2 == 0) {
52 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
53 | transition.animationType = WXSTransitionAnimationTypeViewMoveToNextVC;
54 | transition.animationTime = 0.64;
55 | transition.startView = cell.imgView;
56 | transition.targetView = weakVC.imageView;
57 | }];
58 | }else {
59 |
60 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
61 | transition.animationType = WXSTransitionAnimationTypeViewMoveNormalToNextVC;
62 | transition.animationTime = 0.4;
63 | transition.startView = cell.imgView;
64 | transition.targetView = weakVC.imageView;
65 | }];
66 | }
67 |
68 | }
69 |
70 | #pragma mark Getter
71 | -(UICollectionView *)collectionView{
72 | if (!_collectionView) {
73 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
74 | layout.itemSize = CGSizeMake(100, 100);
75 | _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
76 | _collectionView.delegate = self;
77 | _collectionView.dataSource = self;
78 | _collectionView.backgroundColor = [UIColor whiteColor];
79 | }
80 | return _collectionView;
81 | }
82 |
83 | - (void)didReceiveMemoryWarning {
84 | [super didReceiveMemoryWarning];
85 | }
86 |
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/WXSTransition/DetailViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // DetailViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "WXSBaseViewController.h"
12 | #import "UIViewController+WXSTransition.h"
13 | @interface DetailViewController : WXSBaseViewController
14 | @property (nonatomic,strong) UIImageView *imageView;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/DetailViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // DetailViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "DetailViewController.h"
10 |
11 | @interface DetailViewController ()
12 |
13 |
14 | @end
15 |
16 | @implementation DetailViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | self.view.backgroundColor = [UIColor whiteColor];
22 | [self.view addSubview:self.imageView];
23 |
24 |
25 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
26 | [self.view addGestureRecognizer:tap];
27 | }
28 |
29 | -(void)tapAction {
30 |
31 | [self.navigationController popViewControllerAnimated:YES];
32 |
33 | }
34 | -(UIImageView *)imageView{
35 | if (!_imageView) {
36 | _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
37 | _imageView.center = self.view.center;
38 | _imageView.image = [UIImage imageNamed:@"img"];
39 | }
40 | return _imageView;
41 | }
42 | - (void)didReceiveMemoryWarning {
43 | [super didReceiveMemoryWarning];
44 | // Dispose of any resources that can be recreated.
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/WXSTransition/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | WXSTransition
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UISupportedInterfaceOrientations~ipad
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationPortraitUpsideDown
45 | UIInterfaceOrientationLandscapeLeft
46 | UIInterfaceOrientationLandscapeRight
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/WXSTransition/PageTransition.h:
--------------------------------------------------------------------------------
1 | //
2 | // PageTransition.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface PageTransition : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/WXSTransition/PageTransition.m:
--------------------------------------------------------------------------------
1 | //
2 | // PageTransition.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "PageTransition.h"
10 |
11 | @implementation PageTransition
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/WXSTransition/PresentViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // PresentViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSBaseViewController.h"
10 | @interface PresentViewController : WXSBaseViewController
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/WXSTransition/PresentViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // PresentViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "PresentViewController.h"
10 |
11 | @interface PresentViewController ()
12 |
13 | @end
14 |
15 | @implementation PresentViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | UIImageView *bgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
21 | bgView.image = [UIImage imageNamed:@"bg1"];
22 | [self.view addSubview:bgView];
23 |
24 | self.view.backgroundColor = [UIColor whiteColor];
25 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];
26 | btn.center = self.view.center;
27 | [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
28 | [btn setTitle:@"点我 返回上个界面" forState:UIControlStateNormal];
29 | [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
30 | [self.view addSubview:btn];
31 |
32 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)];
33 | [self.view addGestureRecognizer:tap];
34 |
35 | }
36 |
37 | -(void)click{
38 |
39 | [self dismissViewControllerAnimated:YES completion:nil];
40 |
41 | }
42 |
43 | - (void)didReceiveMemoryWarning {
44 | [super didReceiveMemoryWarning];
45 | // Dispose of any resources that can be recreated.
46 | }
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/WXSTransition/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSBaseViewController.h"
10 | #import "UINavigationController+WXSTransition.h"
11 | @interface SecondViewController : WXSBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/WXSTransition/SecondViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "SecondViewController.h"
10 |
11 | @interface SecondViewController ()
12 |
13 | @end
14 |
15 | @implementation SecondViewController
16 |
17 |
18 | - (void)viewWillAppear:(BOOL)animated {
19 | [super viewWillAppear:animated];
20 |
21 | }
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 |
25 | self.view.backgroundColor = [UIColor whiteColor];
26 |
27 | UIImageView *bgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
28 | bgView.image = [UIImage imageNamed:@"bg2"];
29 | [self.view addSubview:bgView];
30 |
31 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];
32 | btn.center = self.view.center;
33 | [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
34 | [btn setTitle:@"点我 返回上个界面" forState:UIControlStateNormal];
35 | [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
36 | [self.view addSubview:btn];
37 |
38 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)];
39 | [self.view addGestureRecognizer:tap];
40 |
41 | self.title = @"This is push";
42 |
43 | }
44 |
45 | -(void)click{
46 |
47 | [self.navigationController popViewControllerAnimated:YES];
48 | }
49 |
50 | - (void)didReceiveMemoryWarning {
51 | [super didReceiveMemoryWarning];
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/WXSTransition/TableViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // TableViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SecondViewController.h"
11 | #import "PresentViewController.h"
12 | #import "UINavigationController+WXSTransition.h"
13 | @interface TableViewController : UITableViewController
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/WXSTransition/TableViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // TableViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/31.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "TableViewController.h"
10 |
11 | @interface TableViewController ()
12 | {
13 | NSArray *_names;
14 |
15 | }
16 |
17 |
18 | @end
19 |
20 | @implementation TableViewController
21 |
22 | - (void)viewWillAppear:(BOOL)animated {
23 | [super viewWillAppear:animated];
24 | }
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 |
28 | _names = @[@"Fade",
29 | @"Push",@"Push",@"Push",@"Push",
30 | @"Reveal",@"Reveal",@"Reveal",@"Reveal",
31 | @"MoveIn",@"MoveIn",@"MoveIn",@"MoveIn",
32 | @"Cube",@"Cube",@"Cube",@"Cube",
33 | @"suckEffect",
34 | @"oglFlip",@"oglFlip",@"oglFlip",@"oglFlip",
35 | @"rippleEffect",
36 | @"pageCurl",@"pageCurl",@"pageCurl",@"pageCurl",
37 | @"pageUnCurl",@"pageUnCurl",@"pageUnCurl",@"pageUnCurl",
38 | @"CameraIrisHollowOpen",
39 | @"CameraIrisHollowClose"];
40 |
41 |
42 | }
43 |
44 | - (void)didReceiveMemoryWarning {
45 | [super didReceiveMemoryWarning];
46 | }
47 |
48 | #pragma mark - Table view data source
49 |
50 |
51 |
52 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
53 | return WXSTransitionAnimationTypeSysCameraIrisHollowClose;
54 | }
55 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
56 | return 2;
57 | }
58 | -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
59 | return section == 0 ? @"present" : @"push";
60 | }
61 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
62 | static NSString *identifier = @"identifier";
63 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
64 | if (!cell) {
65 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
66 | }
67 | cell.textLabel.text = indexPath.row < WXSTransitionAnimationTypeSysCameraIrisHollowClose ? _names[indexPath.row] : @"转场动画";
68 |
69 | cell.backgroundColor = [UIColor whiteColor] ;
70 | return cell;
71 | }
72 |
73 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
74 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
75 |
76 | if (indexPath.section == 0) {
77 | PresentViewController *vc = [[PresentViewController alloc] init];
78 | [self wxs_presentViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
79 | transition.animationType = indexPath.row + 1;
80 | transition.isSysBackAnimation = (int)rand()%2 < 1 ? YES : NO;
81 | } completion:nil];
82 |
83 | }else{
84 |
85 | SecondViewController *vc = [[SecondViewController alloc] init];
86 |
87 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
88 | transition.animationType = indexPath.row + 1;
89 | // transition.isSysBackAnimation = (int)rand()%2 < 1 ? YES : NO;
90 | }];
91 |
92 | }
93 |
94 |
95 | }
96 |
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/WXSTransition/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SecondViewController.h"
11 | #import "CollectionViewController.h"
12 | #import "PresentViewController.h"
13 | #import "UINavigationController+WXSTransition.h"
14 | #import "TableViewController.h"
15 |
16 | @interface ViewController : UIViewController
17 |
18 |
19 | @end
20 |
21 |
--------------------------------------------------------------------------------
/WXSTransition/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "WXSTestViewController.h"
11 |
12 | @interface ViewController ()
13 | @property (nonatomic,strong) UITableView *tableView;
14 | @property (nonatomic,strong) NSArray *names;
15 | @property (nonatomic,strong) NSArray *customNames;
16 |
17 | @end
18 |
19 | @implementation ViewController
20 | #pragma mark lifecycle
21 | -(void)viewWillAppear:(BOOL)animated{
22 | [super viewWillAppear:animated];
23 | }
24 | - (void)viewDidLoad {
25 | [super viewDidLoad];
26 |
27 |
28 | UIImageView *bgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
29 | bgView.image = [UIImage imageNamed:@"bg4"];
30 | [self.view addSubview:bgView];
31 | [self.view addSubview:self.tableView];
32 |
33 | self.navigationController.view.layer.cornerRadius = 7.0;
34 | self.navigationController.view.layer.masksToBounds = YES;
35 |
36 | _names = @[@"pageTransition",@"viewMove",@"viewMove",@"cover",@"spreadFromRight",@"spreadFromLeft",@"spreadFromTop",@"spreadFromBottom",@"point spread",@"boom",@"brick openV",@"brick openH",@"brick closeV",@"brick closeH",@"InsideThenPush",@"fragmentShowFromRight",@"fragmentShowFromLeft",@"fragmentShowFromTop",@"fragmentShowFromBottom",@"fragmenHideFromRight",@"fragmenHideFromLeft",@"fragmenHideFromTop",@"fragmenHideFromBottom",@"tip flip"];
37 | _customNames = @[@"poitnt spread from tap center",@"test "];
38 |
39 | }
40 | #pragma mark Delegate
41 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
42 | switch (section) {
43 | case 0:
44 | return 1;
45 | break;
46 | case 1:
47 | case 2:
48 | return WXSTransitionAnimationTypeTipFlip - WXSTransitionAnimationTypeDefault;
49 | break;
50 | default:
51 | return _customNames.count;
52 | break;
53 | }
54 | }
55 |
56 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
57 | return 4;
58 | }
59 |
60 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
61 |
62 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 25)];
63 | label.font = [UIFont systemFontOfSize:25];
64 |
65 | label.backgroundColor = [UIColor clearColor];
66 | label.textAlignment = NSTextAlignmentCenter;
67 | switch (section) {
68 | case 0:
69 | label.text = @"systerm";
70 | break;
71 | case 1:
72 | label.text = @"push";
73 | break;
74 | case 2:
75 | label.text = @"present";
76 | break;
77 | default:
78 | label.text = @"custom";
79 | break;
80 | }
81 |
82 | return label;
83 | }
84 |
85 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
86 | return 26;
87 | }
88 | -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
89 | return 0.000001;
90 | }
91 |
92 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
93 | static NSString *Identifier = @"wxsIdentifier";
94 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
95 | if (!cell) {
96 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
97 | cell.backgroundColor = [UIColor clearColor];
98 | }
99 | switch (indexPath.section) {
100 | case 0:
101 | cell.textLabel.text = @"systerm";
102 | break;
103 | case 1:
104 | case 2:
105 | cell.textLabel.text = indexPath.row < _names.count ? _names[indexPath.row] : @"other";
106 | break;
107 | default:
108 | cell.textLabel.text = indexPath.row < _customNames.count ? _customNames[indexPath.row] : @"other";
109 | break;
110 | }
111 | cell.imageView.image = [UIImage imageNamed:@"start"];
112 | return cell;
113 | }
114 |
115 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
116 |
117 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
118 |
119 | switch (indexPath.section) {
120 | case 0:{
121 | TableViewController *vc = [[TableViewController alloc] init];
122 | [self.navigationController pushViewController:vc animated:YES];
123 | }
124 | break;
125 | case 1:{
126 | if (indexPath.row == 1 || indexPath.row == 2) {
127 | CollectionViewController *vc = [[CollectionViewController alloc] init];
128 | self.navigationController.delegate = nil;
129 | [self.navigationController pushViewController:vc animated:YES];
130 | return;
131 | }
132 |
133 | [self.navigationController wxs_pushViewController:[[SecondViewController alloc] init] makeTransition:^(WXSTransitionProperty *transition) {
134 | transition.backGestureType = WXSGestureTypePanRight;
135 | transition.animationType =WXSTransitionAnimationTypePageTransition + indexPath.row;
136 | }];
137 |
138 |
139 | }
140 | break;
141 | case 2:{
142 | if (indexPath.row == 1 || indexPath.row == 2) {
143 | CollectionViewController *vc = [[CollectionViewController alloc] init];
144 | [self.navigationController pushViewController:vc animated:YES];
145 | return;
146 | }
147 | [self wxs_presentViewController:[[PresentViewController alloc] init] animationType:WXSTransitionAnimationTypePageTransition + indexPath.row completion:nil];
148 |
149 | }
150 | break;
151 |
152 | default:{
153 | switch (indexPath.row) {
154 | case 0:{
155 |
156 | UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
157 | SecondViewController *vc = [[SecondViewController alloc] init];
158 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
159 | transition.animationType = WXSTransitionAnimationTypePointSpreadPresent;
160 | transition.animationTime = 1;
161 | transition.backGestureEnable = NO;
162 | transition.startView = cell.contentView;
163 | }];
164 | }
165 | break;
166 | case 1:{
167 |
168 | WXSTestViewController *vc = [[WXSTestViewController alloc] init];
169 | [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
170 | transition.animationType = WXSTransitionAnimationTypeSpreadFromBottom;
171 | transition.isSysBackAnimation = YES;
172 | }];
173 | }
174 |
175 | default:
176 | break;
177 | }
178 | }
179 | break;
180 | }
181 |
182 | }
183 |
184 | #pragma mark Getter
185 | -(UITableView *)tableView {
186 | if (!_tableView) {
187 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64) style:UITableViewStyleGrouped];
188 | _tableView.delegate = self;
189 | _tableView.dataSource = self;
190 | _tableView.backgroundColor = [UIColor clearColor];
191 | }
192 | return _tableView;
193 | }
194 | - (void)didReceiveMemoryWarning {
195 | [super didReceiveMemoryWarning];
196 | }
197 |
198 | @end
199 |
--------------------------------------------------------------------------------
/WXSTransition/WXSBaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSBaseViewController.h
3 | // WXSTransition
4 | //
5 | // Created by thejoyrun on 16/7/8.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WXSBaseViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/WXSTransition/WXSBaseViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSBaseViewController.m
3 | // WXSTransition
4 | //
5 | // Created by thejoyrun on 16/7/8.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSBaseViewController.h"
10 |
11 | @interface WXSBaseViewController ()
12 |
13 | @end
14 |
15 | @implementation WXSBaseViewController
16 |
17 | -(void)dealloc {
18 | NSLog(@"%@ dealloc", NSStringFromClass([self class]));
19 | }
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | }
24 |
25 | - (void)viewWillAppear:(BOOL)animated {
26 | [super viewWillAppear:animated];
27 | }
28 |
29 | - (void)didReceiveMemoryWarning {
30 | [super didReceiveMemoryWarning];
31 | }
32 |
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTestViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTestViewController.h
3 | // WXSTransition
4 | //
5 | // Created by wangxiaoshu on 2017/6/19.
6 | // Copyright © 2017年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WXSTestViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTestViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTestViewController.m
3 | // WXSTransition
4 | //
5 | // Created by wangxiaoshu on 2017/6/19.
6 | // Copyright © 2017年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTestViewController.h"
10 | #import "UINavigationController+WXSTransition.h"
11 | #import "WXSTestViewController.h"
12 | @interface WXSTestViewController ()
13 |
14 | @end
15 |
16 | @implementation WXSTestViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | self.view.backgroundColor = [UIColor whiteColor];
22 | UIImageView *bgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
23 | bgView.image = [UIImage imageNamed:@"bg4"];
24 | [self.view addSubview:bgView];
25 |
26 |
27 | UIButton *btn = [[UIButton alloc] init];
28 | btn.frame = CGRectMake(30, 100, 200, 50);
29 | [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
30 | [btn setTitle:@"多级跳转" forState:UIControlStateNormal];
31 | [btn addTarget:self action:@selector(multiVC) forControlEvents:UIControlEventTouchUpInside];
32 | [self.view addSubview:btn];
33 |
34 |
35 | UIButton *btn1 = [[UIButton alloc] init];
36 | btn1.frame = CGRectMake(30, 200, 200, 50);
37 | [btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
38 | [btn1 setTitle:@"无自定义" forState:UIControlStateNormal];
39 | [btn1 addTarget:self action:@selector(nomalPush) forControlEvents:UIControlEventTouchUpInside];
40 | [self.view addSubview:btn1];
41 |
42 | }
43 | - (void)multiVC {
44 | WXSTestViewController *vc = [[WXSTestViewController alloc] init];
45 | [self.navigationController wxs_pushViewController:vc animationType:WXSTransitionAnimationTypeBrickCloseVertical];
46 | }
47 |
48 | - (void)nomalPush {
49 | WXSTestViewController *vc = [[WXSTestViewController alloc] init];
50 | [self.navigationController pushViewController:vc animated:YES];
51 | }
52 | - (void)didReceiveMemoryWarning {
53 | [super didReceiveMemoryWarning];
54 | }
55 |
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UINavigationController+WXSTransition.h:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationController+WXSTransition.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/3.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WXSTypedefConfig.h"
11 | #import "UIViewController+WXSTransition.h"
12 |
13 |
14 | @interface UINavigationController (WXSTransition)
15 |
16 | /*
17 | *
18 | */
19 | - (void)wxs_pushViewController:(UIViewController *)viewController animationType:(WXSTransitionAnimationType) animationType;
20 | - (void)wxs_pushViewController:(UIViewController *)viewController makeTransition:(WXSTransitionBlock) transitionBlock;
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UINavigationController+WXSTransition.m:
--------------------------------------------------------------------------------
1 | //
2 | // UINavigationController+WXSTransition.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/3.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "UINavigationController+WXSTransition.h"
10 | #import
11 | #import "UIViewController+WXSTransitionProperty.h"
12 | @implementation UINavigationController (WXSTransition)
13 |
14 |
15 | #pragma mark Hook
16 | +(void)load {
17 |
18 | static dispatch_once_t onceToken;
19 | dispatch_once(&onceToken, ^{
20 |
21 | Method method0 = class_getInstanceMethod(self.class, @selector(popViewControllerAnimated:));
22 | Method method1 = class_getInstanceMethod(self.class, @selector(wxs_popViewControllerAnimated:));
23 | method_exchangeImplementations(method0, method1);
24 |
25 | });
26 | }
27 | #pragma mark Action Method
28 | - (void)wxs_pushViewController:(UIViewController *)viewController {
29 |
30 | [self wxs_pushViewController:viewController makeTransition:nil];
31 |
32 | }
33 |
34 | - (void)wxs_pushViewController:(UIViewController *)viewController animationType:(WXSTransitionAnimationType) animationType{
35 |
36 | [self wxs_pushViewController:viewController makeTransition:^(WXSTransitionProperty *transition) {
37 | transition.animationType = animationType;
38 | }];
39 | }
40 |
41 | - (void)wxs_pushViewController:(UIViewController *)viewController makeTransition:(WXSTransitionBlock) transitionBlock {
42 |
43 | if (self.delegate) {
44 | viewController.wxs_tempNavDelegate = self.delegate;
45 | }
46 | self.delegate = viewController;
47 | viewController.wxs_addTransitionFlag = YES;
48 | viewController.wxs_callBackTransition = transitionBlock ? transitionBlock : nil;
49 |
50 | [self pushViewController:viewController animated:YES];
51 | self.delegate = nil;
52 | if (viewController.wxs_tempNavDelegate) {
53 | self.delegate = viewController.wxs_tempNavDelegate;
54 | }
55 |
56 | }
57 |
58 | - (UIViewController *)wxs_popViewControllerAnimated:(BOOL)animated {
59 |
60 | if (self.viewControllers.lastObject.wxs_delegateFlag) {
61 | self.delegate = self.viewControllers.lastObject;
62 | if (self.wxs_tempNavDelegate) {
63 | self.delegate = self.wxs_tempNavDelegate;
64 | }
65 | }
66 | return [self wxs_popViewControllerAnimated:animated];
67 |
68 | }
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UIViewController+WXSTransition.h:
--------------------------------------------------------------------------------
1 |
2 | #import
3 | #import "WXSTransitionManager.h"
4 | #import "WXSTransitionProperty.h"
5 | #import "WXSPercentDrivenInteractiveTransition.h"
6 |
7 | typedef void(^WXSTransitionBlock)(WXSTransitionProperty *transition);
8 |
9 | @interface UIViewController (WXSTransition)
10 |
11 |
12 | - (void)wxs_presentViewController:(UIViewController *)viewControllerToPresent animationType:(WXSTransitionAnimationType )animationType completion:(void (^)(void))completion;
13 | - (void)wxs_presentViewController:(UIViewController *)viewControllerToPresent makeTransition:(WXSTransitionBlock)transitionBlock;
14 | - (void)wxs_presentViewController:(UIViewController *)viewControllerToPresent makeTransition:(WXSTransitionBlock)transitionBlock completion:(void (^)(void))completion;
15 |
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UIViewController+WXSTransition.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | #import "UIViewController+WXSTransition.h"
4 | #import
5 | #import "UIViewController+WXSTransitionProperty.h"
6 |
7 |
8 |
9 |
10 | UINavigationControllerOperation _operation;
11 | WXSPercentDrivenInteractiveTransition *_interactive;
12 | WXSTransitionManager *_transtion;
13 |
14 |
15 | @implementation UIViewController (WXSTransition)
16 | #pragma mark Hook
17 |
18 | + (void)load {
19 | static dispatch_once_t onceToken;
20 | dispatch_once(&onceToken, ^{
21 |
22 |
23 | Method method0 = class_getInstanceMethod(self.class, @selector(wxs_dismissViewControllerAnimated:completion:));
24 | Method method1 = class_getInstanceMethod(self.class, @selector(dismissViewControllerAnimated:completion:));
25 | method_exchangeImplementations(method0, method1);
26 |
27 | SEL originalSelector = @selector(viewDidAppear:);
28 | SEL swizzledSelector = @selector(wxs_viewDidAppear:);
29 |
30 | Method originalMethod = class_getInstanceMethod(self.class, originalSelector);
31 | Method swizzledMethod = class_getInstanceMethod(self.class, swizzledSelector);
32 |
33 | BOOL success = class_addMethod(self.class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
34 | if (success) {
35 | class_replaceMethod(self.class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
36 | } else {
37 | method_exchangeImplementations(originalMethod, swizzledMethod);
38 | }
39 |
40 |
41 |
42 |
43 | originalSelector = @selector(viewWillDisappear:);
44 | swizzledSelector = @selector(wxs_viewWillDisappear:);
45 |
46 | originalMethod = class_getInstanceMethod(self.class, originalSelector);
47 | swizzledMethod = class_getInstanceMethod(self.class, swizzledSelector);
48 |
49 | success = class_addMethod(self.class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
50 | if (success) {
51 | class_replaceMethod(self.class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
52 | } else {
53 | method_exchangeImplementations(originalMethod, swizzledMethod);
54 | }
55 |
56 | });
57 | }
58 |
59 |
60 |
61 | - (void)wxs_dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
62 | if (self.wxs_delegateFlag) {
63 | self.transitioningDelegate = self;
64 | if (self.wxs_transitioningDelegate) {
65 | self.transitioningDelegate = self.wxs_transitioningDelegate;
66 | }
67 | }
68 | [self wxs_dismissViewControllerAnimated:flag completion:completion];
69 | }
70 |
71 | - (void)wxs_viewDidAppear:(BOOL)animated {
72 |
73 | [self wxs_viewDidAppear:animated];
74 | }
75 |
76 |
77 | - (void)wxs_viewWillDisappear:(BOOL)animated {
78 | [self wxs_viewWillDisappear:animated];
79 |
80 | }
81 |
82 |
83 |
84 | #pragma mark Action Method
85 |
86 | //Default
87 | - (void)wxs_presentViewController:(UIViewController *)viewControllerToPresent completion:(void (^)(void))completion{
88 |
89 | [self wxs_presentViewController:viewControllerToPresent makeTransition:nil completion:completion];
90 | }
91 |
92 | //Choose animation type
93 | -(void)wxs_presentViewController:(UIViewController *)viewControllerToPresent animationType:(WXSTransitionAnimationType )animationType completion:(void (^)(void))completion{
94 |
95 | [self wxs_presentViewController:viewControllerToPresent makeTransition:^(WXSTransitionProperty *transition) {
96 | transition.animationType = animationType;
97 | } completion:completion];
98 |
99 |
100 | }
101 |
102 | //make transition
103 | -(void)wxs_presentViewController:(UIViewController *)viewControllerToPresent makeTransition:(WXSTransitionBlock)transitionBlock{
104 |
105 | [self wxs_presentViewController:viewControllerToPresent makeTransition:transitionBlock completion:nil];
106 |
107 | }
108 |
109 | //make transition With Completion
110 | -(void)wxs_presentViewController:(UIViewController *)viewControllerToPresent makeTransition:(WXSTransitionBlock)transitionBlock completion:(void (^)(void))completion{
111 |
112 | if (viewControllerToPresent.transitioningDelegate) {
113 | self.wxs_transitioningDelegate = viewControllerToPresent.transitioningDelegate;
114 | }
115 | viewControllerToPresent.wxs_addTransitionFlag = YES;
116 | viewControllerToPresent.transitioningDelegate = viewControllerToPresent;
117 | viewControllerToPresent.wxs_callBackTransition = transitionBlock ? transitionBlock : nil;
118 | [self presentViewController:viewControllerToPresent animated:YES completion:completion];
119 |
120 | }
121 |
122 |
123 |
124 |
125 | #pragma mark Delegate
126 | // ********************** Present Dismiss **********************
127 | -(id)animationControllerForDismissedController:(UIViewController *)dismissed {
128 |
129 | if (!self.wxs_addTransitionFlag) {
130 | return nil;//dimiss directly
131 | }
132 |
133 | !_transtion ? _transtion = [[WXSTransitionManager alloc] init] : nil ;
134 | WXSTransitionProperty *make = [[WXSTransitionProperty alloc] init];
135 | self.wxs_callBackTransition ? self.wxs_callBackTransition(make) : nil;
136 | _transtion = [WXSTransitionManager copyPropertyFromObjcet:make toObjcet:_transtion];
137 | _transtion.transitionType = WXSTransitionTypeDismiss;
138 | self.wxs_backGestureEnable = make.backGestureEnable;
139 | return _transtion;
140 |
141 | }
142 | -(id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
143 |
144 | if (!self.wxs_addTransitionFlag) {
145 | return nil;//present directly
146 | }
147 |
148 | !_transtion ? _transtion = [[WXSTransitionManager alloc] init] : nil ;
149 | WXSTransitionProperty *make = [[WXSTransitionProperty alloc] init];
150 | self.wxs_callBackTransition ? self.wxs_callBackTransition(make) : nil;
151 | _transtion = [WXSTransitionManager copyPropertyFromObjcet:make toObjcet:_transtion];
152 | _transtion.transitionType = WXSTransitionTypePresent;
153 | self.wxs_delegateFlag = _transtion.isSysBackAnimation ? NO : YES;
154 | self.wxs_backGestureEnable = make.backGestureEnable;
155 | return _transtion;
156 |
157 | }
158 |
159 | - (id )interactionControllerForPresentation:(id )animator{
160 | return nil;
161 | }
162 |
163 | - (id )interactionControllerForDismissal:(id )animator{
164 | if (!self.wxs_addTransitionFlag) {
165 | return nil;
166 | }
167 | return _interactive.isInteractive ? _interactive : nil ;
168 | }
169 |
170 |
171 | // ********************** Push Pop **********************
172 | -(id)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC{
173 |
174 | if (!self.wxs_addTransitionFlag) {
175 | return nil;
176 | }
177 | !_transtion ? _transtion = [[WXSTransitionManager alloc] init] : nil ;
178 | WXSTransitionProperty *make = [[WXSTransitionProperty alloc] init];
179 | self.wxs_callBackTransition ? self.wxs_callBackTransition(make) : nil;
180 | _transtion = [WXSTransitionManager copyPropertyFromObjcet:make toObjcet:_transtion];
181 | _operation = operation;
182 |
183 |
184 | if ( operation == UINavigationControllerOperationPush ) {
185 | self.wxs_delegateFlag = _transtion.isSysBackAnimation ? NO : YES;
186 | _transtion.transitionType = WXSTransitionTypePush;
187 |
188 | }else{
189 | _transtion.transitionType = WXSTransitionTypePop;
190 | }
191 |
192 | if (_operation == UINavigationControllerOperationPush && _transtion.isSysBackAnimation == NO && _transtion.backGestureEnable) {
193 | //add gestrue for pop
194 | !_interactive ? _interactive = [[WXSPercentDrivenInteractiveTransition alloc] init] : nil;
195 | [_interactive addGestureToViewController:self];
196 | _interactive.transitionType = WXSTransitionTypePop;
197 | _interactive.getstureType = _transtion.backGestureType != WXSGestureTypeNone ? _transtion.backGestureType : WXSGestureTypePanRight;
198 | _interactive.willEndInteractiveBlock = ^(BOOL suceess) {
199 | _transtion.willEndInteractiveBlock ? _transtion.willEndInteractiveBlock(suceess) : nil;
200 | };
201 |
202 | }
203 | self.wxs_backGestureEnable = make.backGestureEnable;
204 | return _transtion;
205 |
206 | }
207 | - (nullable id )navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id ) animationController {
208 |
209 | if (!self.wxs_addTransitionFlag) {
210 | return nil;
211 | }
212 | !_interactive ? _interactive = [[WXSPercentDrivenInteractiveTransition alloc] init] : nil;
213 |
214 | if (_operation == UINavigationControllerOperationPush) {
215 | return nil;
216 | }else{
217 | return _interactive.isInteractive ? _interactive : nil ;
218 | }
219 |
220 | }
221 |
222 |
223 | @end
224 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UIViewController+WXSTransitionProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+WXSTransitionProperty.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/21.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class WXSTransitionProperty;
12 |
13 |
14 | @interface UIViewController (WXSTransitionProperty)
15 |
16 |
17 | typedef void(^WXSTransitionBlock)(WXSTransitionProperty *transition);
18 |
19 | @property (nonatomic, copy ) WXSTransitionBlock wxs_callBackTransition;
20 | @property (nonatomic, assign) BOOL wxs_delegateFlag;
21 | @property (nonatomic, assign) BOOL wxs_addTransitionFlag;
22 | @property (nonatomic, assign) BOOL wxs_backGestureEnable;
23 |
24 | @property (nonatomic, weak ) id wxs_transitioningDelegate;
25 | @property (nonatomic, weak ) id wxs_tempNavDelegate;
26 |
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/UIViewController+WXSTransitionProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+WXSTransitionProperty.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/21.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "UIViewController+WXSTransitionProperty.h"
10 | #import
11 |
12 |
13 | static NSString *wxs_callBackTransitionKey = @"CallBackTransitionKey";
14 | static NSString *wxs_delegateFlagKey = @"wxs_DelegateFlagKey";
15 | static NSString *wxs_addTransitionFlagKey = @"wxs_addTransitionFlagKey";
16 | static NSString *wxs_backGestureEnableKey = @"wxs_backGestureEnableKey";
17 | static NSString *wxs_transitioningDelegateKey = @"wxs_transitioningDelegateKey";
18 | static NSString *wxs_tempNavDelegateKey = @"wxs_tempNavDelegateKey";
19 |
20 |
21 |
22 | @implementation UIViewController (WXSTransitionProperty)
23 |
24 |
25 | #pragma mark Property
26 |
27 |
28 | //----- CallBackTransition
29 | - (void)setWxs_callBackTransition:(WXSTransitionBlock)wxs_callBackTransition {
30 | objc_setAssociatedObject(self, &wxs_callBackTransitionKey, wxs_callBackTransition, OBJC_ASSOCIATION_COPY);
31 | }
32 | - (WXSTransitionBlock)wxs_callBackTransition {
33 | return objc_getAssociatedObject(self, &wxs_callBackTransitionKey);
34 | }
35 |
36 | //----- wxs_DelegateFlag
37 | - (void)setWxs_delegateFlag:(BOOL)wxs_delegateFlag {
38 | objc_setAssociatedObject(self, &wxs_delegateFlagKey, @(wxs_delegateFlag), OBJC_ASSOCIATION_ASSIGN);
39 | }
40 | -(BOOL)wxs_delegateFlag {
41 | return [objc_getAssociatedObject(self, &wxs_delegateFlagKey) integerValue] == 0 ? NO : YES;
42 | }
43 |
44 |
45 | //----- wxs_addTransitionFlag
46 | - (void)setWxs_addTransitionFlag:(BOOL)wxs_addTransitionFlag {
47 | objc_setAssociatedObject(self, &wxs_addTransitionFlagKey, @(wxs_addTransitionFlag), OBJC_ASSOCIATION_ASSIGN);
48 | }
49 | - (BOOL)wxs_addTransitionFlag {
50 | return [objc_getAssociatedObject(self, &wxs_addTransitionFlagKey) integerValue] == 0 ? NO : YES;
51 | }
52 |
53 |
54 | // ---- wxs_backGestureEnable
55 | - (void)setWxs_backGestureEnable:(BOOL)wxs_backGestureEnable {
56 | objc_setAssociatedObject(self, &wxs_backGestureEnableKey, @(wxs_backGestureEnable), OBJC_ASSOCIATION_ASSIGN);
57 | }
58 |
59 | - (BOOL)wxs_backGestureEnable {
60 | return [objc_getAssociatedObject(self , &wxs_backGestureEnableKey) integerValue] == 0 ? NO : YES;
61 | }
62 |
63 | //----- Wxs_transitioningDelega
64 | - (void)setWxs_transitioningDelegate:(id)wxs_transitioningDelegate {
65 | objc_setAssociatedObject(self, &wxs_transitioningDelegateKey, wxs_transitioningDelegate, OBJC_ASSOCIATION_ASSIGN);
66 | }
67 |
68 | - (id)wxs_transitioningDelegate {
69 | return objc_getAssociatedObject(self, &wxs_transitioningDelegateKey);
70 | }
71 | //----- wxs_tempNavDelegate
72 | - (void)setWxs_tempNavDelegate:(id)wxs_tempNavDelegate {
73 | objc_setAssociatedObject(self, &wxs_tempNavDelegateKey, wxs_tempNavDelegate, OBJC_ASSOCIATION_ASSIGN);
74 | }
75 | - (id)wxs_tempNavDelegate {
76 | return objc_getAssociatedObject(self, &wxs_tempNavDelegateKey);
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSPercentDrivenInteractiveTransition.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSPercentDrivenInteractiveTransition.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WXSTypedefConfig.h"
11 |
12 | typedef void(^ActionBlock)(void);
13 |
14 | //继承自 实现了UIViewControllerInteractiveTransitioning协议的UIPercentDrivenInteractiveTransition
15 | @interface WXSPercentDrivenInteractiveTransition : UIPercentDrivenInteractiveTransition
16 |
17 | @property (nonatomic, assign) WXSGestureType getstureType;
18 | @property (readonly, assign, nonatomic) BOOL isInteractive;
19 | @property (nonatomic, assign) WXSTransitionType transitionType;
20 |
21 | @property (nonatomic, copy) ActionBlock presentBlock;
22 | @property (nonatomic, copy) ActionBlock pushBlock;
23 | @property (nonatomic, copy) ActionBlock dismissBlock;
24 | @property (nonatomic, copy) ActionBlock popBlock;
25 |
26 | @property (nonatomic, copy) void(^willEndInteractiveBlock)(BOOL success);
27 |
28 | -(void)addGestureToViewController:(UIViewController *)vc;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSPercentDrivenInteractiveTransition.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSPercentDrivenInteractiveTransition.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSPercentDrivenInteractiveTransition.h"
10 | @interface WXSPercentDrivenInteractiveTransition ()
11 | {
12 | BOOL _isInter;
13 | }
14 |
15 | @property (nonatomic, weak ) UIViewController *vc; //
16 | @property (nonatomic, strong) CADisplayLink *displayLink;
17 | @property (nonatomic, assign) CGFloat percent;
18 |
19 |
20 |
21 | @end
22 |
23 | @implementation WXSPercentDrivenInteractiveTransition
24 |
25 | -(void)addGestureToViewController:(UIViewController *)vc{
26 |
27 | UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
28 | self.vc = vc;
29 | [vc.view addGestureRecognizer:pan];
30 | }
31 |
32 | -(void)panAction:(UIPanGestureRecognizer *)pan{
33 |
34 | _percent = 0.0;
35 | CGFloat totalWidth = pan.view.bounds.size.width;
36 | CGFloat totalHeight = pan.view.bounds.size.height;
37 | switch (self.getstureType) {
38 |
39 | case WXSGestureTypePanLeft:{
40 | CGFloat x = [pan translationInView:pan.view].x;
41 | _percent = -x/totalWidth;
42 | }
43 | break;
44 | case WXSGestureTypePanRight:{
45 | CGFloat x = [pan translationInView:pan.view].x;
46 | _percent = x/totalWidth;
47 | }
48 | break;
49 | case WXSGestureTypePanDown:{
50 |
51 | CGFloat y = [pan translationInView:pan.view].y;
52 | _percent = y/totalHeight;
53 |
54 | }
55 | break;
56 | case WXSGestureTypePanUp:{
57 | CGFloat y = [pan translationInView:pan.view].y;
58 | _percent = -y/totalHeight;
59 | }
60 |
61 | default:
62 | break;
63 | }
64 |
65 | switch (pan.state) {
66 | case UIGestureRecognizerStateBegan:{
67 | _isInter = YES;
68 | [self beganGesture];
69 | }
70 | break;
71 | case UIGestureRecognizerStateChanged:{
72 | [self updateInteractiveTransition:_percent];
73 | }
74 | break;
75 | case UIGestureRecognizerStateEnded:{
76 | _isInter = NO;
77 |
78 | [self continueAction];
79 |
80 | }
81 | break;
82 | default:
83 | break;
84 | }
85 | }
86 |
87 |
88 |
89 | -(void)beganGesture{
90 |
91 | switch (_transitionType) {
92 | case WXSTransitionTypePresent:{
93 | _presentBlock? _presentBlock() : nil;
94 | }
95 | break;
96 | case WXSTransitionTypeDismiss:{
97 | _dismissBlock ? _dismissBlock() : [_vc dismissViewControllerAnimated:YES completion:^{
98 | }];
99 | }
100 | break;
101 | case WXSTransitionTypePush: {
102 | _pushBlock ? _pushBlock() : nil;
103 | }
104 | break;
105 | case WXSTransitionTypePop:{
106 | _popBlock ? _popBlock() : [_vc.navigationController popViewControllerAnimated:YES];
107 |
108 | }
109 | break;
110 | default:
111 | break;
112 | }
113 |
114 | }
115 |
116 | - (BOOL)isInteractive {
117 | return _isInter;
118 | }
119 |
120 | - (void)continueAction{
121 | if (_displayLink) {
122 | return;
123 | }
124 | _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(UIChange)];
125 | [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
126 |
127 | }
128 |
129 | - (void)UIChange {
130 |
131 | CGFloat timeDistance = 2.0/60;
132 | if (_percent > 0.4) {
133 | _percent += timeDistance;
134 | }else {
135 | _percent -= timeDistance;
136 | }
137 | [self updateInteractiveTransition:_percent];
138 |
139 | if (_percent >= 1.0) {
140 |
141 | _willEndInteractiveBlock ? _willEndInteractiveBlock(YES) : nil;
142 | [self finishInteractiveTransition];
143 | [_displayLink invalidate];
144 | _displayLink = nil;
145 | }
146 |
147 | if (_percent <= 0.0) {
148 |
149 | _willEndInteractiveBlock ? _willEndInteractiveBlock(NO) : nil;
150 |
151 | [_displayLink invalidate];
152 | _displayLink = nil;
153 | [self cancelInteractiveTransition];
154 | }
155 | }
156 |
157 |
158 | @end
159 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+BoomAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+BoomAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (BoomAnimation)
12 |
13 | -(void)boomPresentTransitionNextAnimation:(id)transitionContext;
14 | -(void)boomPresentTransitionBackAnimation:(id)transitionContext;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+BoomAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+BoomAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+BoomAnimation.h"
10 |
11 | @implementation WXSTransitionManager (BoomAnimation)
12 |
13 |
14 |
15 | -(void)boomPresentTransitionNextAnimation:(id)transitionContext{
16 |
17 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
18 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
19 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
20 | UIView *containView = [transitionContext containerView];
21 |
22 | [containView addSubview:toVC.view];
23 | [containView addSubview:fromVC.view];
24 | [containView addSubview:tempView];
25 |
26 | tempView.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
27 |
28 | [UIView animateWithDuration:self.animationTime delay:0.0 usingSpringWithDamping:0.4 initialSpringVelocity:1/0.4 options:0 animations:^{
29 | tempView.layer.transform = CATransform3DIdentity;
30 | } completion:^(BOOL finished) {
31 |
32 | if ([transitionContext transitionWasCancelled]) {
33 | [transitionContext completeTransition:NO];
34 | }else{
35 | [transitionContext completeTransition:YES];
36 | toVC.view.hidden = NO;
37 | }
38 | [tempView removeFromSuperview];
39 | }];
40 |
41 | }
42 |
43 | -(void)boomPresentTransitionBackAnimation:(id)transitionContext{
44 |
45 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
46 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
47 | UIView *tempView = [fromVC.view snapshotViewAfterScreenUpdates:NO];
48 | UIView *containView = [transitionContext containerView];
49 |
50 |
51 | [containView addSubview:toVC.view];
52 | [containView addSubview:tempView];
53 |
54 | tempView.layer.transform = CATransform3DIdentity;
55 |
56 | [UIView animateWithDuration:self.animationTime animations:^{
57 | tempView.layer.transform = CATransform3DMakeScale(0.01, 0.01, 1);
58 | } completion:^(BOOL finished) {
59 |
60 | if ([transitionContext transitionWasCancelled]) {
61 |
62 | [transitionContext completeTransition:NO];
63 | fromVC.view.hidden = NO;
64 | [tempView removeFromSuperview];
65 |
66 | }else{
67 | [transitionContext completeTransition:YES];
68 | toVC.view.hidden = NO;
69 | fromVC.view.hidden = YES;
70 | [tempView removeFromSuperview];
71 | }
72 |
73 | }];
74 |
75 | self.willEndInteractiveBlock = ^(BOOL sucess) {
76 | if (sucess) {
77 | [tempView removeFromSuperview];
78 | }else{
79 | }
80 | };
81 |
82 | }
83 |
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+BrickAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+BrickAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (BrickAnimation)
12 |
13 | - (void)brickOpenNextWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext;
14 | - (void)brickOpenBackWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext;
15 | - (void)brickCloseNextWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext;
16 | - (void)brickCloseBackWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+BrickAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+BrickAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+BrickAnimation.h"
10 |
11 |
12 | @implementation WXSTransitionManager (BrickAnimation)
13 |
14 |
15 | - (void)brickOpenNextWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext {
16 |
17 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
18 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
19 | UIView *containView = [transitionContext containerView];
20 |
21 |
22 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
23 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
24 |
25 | CGRect rect0 ;
26 | CGRect rect1;
27 |
28 | switch (type) {
29 | case WXSTransitionAnimationTypeBrickOpenHorizontal:
30 | rect0 = CGRectMake(0 , 0 , screenWidth/2, screenHeight);
31 | rect1 = CGRectMake(screenWidth/2 , 0 , screenWidth/2, screenHeight);
32 | break;
33 | default:
34 | rect0 = CGRectMake(0 , 0 , screenWidth, screenHeight/2);
35 | rect1 = CGRectMake(0 , screenHeight/2 , screenWidth, screenHeight/2);
36 | break;
37 | }
38 |
39 | UIImage *image0 = [self imageFromView:fromVC.view atFrame:rect0];
40 | UIImage *image1 = [self imageFromView:fromVC.view atFrame:rect1];
41 |
42 | UIImageView *imgView0 = [[UIImageView alloc] initWithImage:image0];
43 | UIImageView *imgView1 = [[UIImageView alloc] initWithImage:image1];
44 |
45 | [containView addSubview:fromVC.view];
46 | [containView addSubview:toVC.view];
47 | [containView addSubview:imgView0];
48 | [containView addSubview:imgView1];
49 |
50 |
51 | [UIView animateWithDuration:self.animationTime animations:^{
52 |
53 | switch (type) {
54 | case WXSTransitionAnimationTypeBrickOpenHorizontal:
55 | imgView0.layer.transform = CATransform3DMakeTranslation(-screenWidth/2, 0, 0);
56 | imgView1.layer.transform = CATransform3DMakeTranslation(screenWidth/2, 0, 0);
57 | break;
58 | default:
59 | imgView0.layer.transform = CATransform3DMakeTranslation(0, -screenHeight/2, 0);
60 | imgView1.layer.transform = CATransform3DMakeTranslation(0, screenHeight/2, 0);
61 | break;
62 | }
63 |
64 | } completion:^(BOOL finished) {
65 |
66 | if ([transitionContext transitionWasCancelled]) {
67 |
68 | [transitionContext completeTransition:NO];
69 | [imgView0 removeFromSuperview];
70 | [imgView1 removeFromSuperview];
71 |
72 | }else{
73 | [transitionContext completeTransition:YES];
74 | [imgView0 removeFromSuperview];
75 | [imgView1 removeFromSuperview];
76 | }
77 | }];
78 |
79 | }
80 |
81 | - (void)brickOpenBackWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext {
82 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
83 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
84 | UIView *containView = [transitionContext containerView];
85 |
86 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
87 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
88 |
89 | CGRect rect0 ;
90 | CGRect rect1;
91 |
92 | switch (type) {
93 | case WXSTransitionAnimationTypeBrickOpenHorizontal:
94 | rect0 = CGRectMake(0 , 0 , screenWidth/2, screenHeight);
95 | rect1 = CGRectMake(screenWidth/2 , 0 , screenWidth/2, screenHeight);
96 | break;
97 | default:
98 | rect0 = CGRectMake(0 , 0 , screenWidth, screenHeight/2);
99 | rect1 = CGRectMake(0 , screenHeight/2 , screenWidth, screenHeight/2);
100 | break;
101 | }
102 |
103 | UIImage *image0 = [self imageFromView:toVC.view atFrame:rect0];
104 | UIImage *image1 = [self imageFromView:toVC.view atFrame:rect1];
105 |
106 | UIImageView *imgView0 = [[UIImageView alloc] initWithImage:image0];
107 | UIImageView *imgView1 = [[UIImageView alloc] initWithImage:image1];
108 |
109 | [containView addSubview:fromVC.view];
110 | [containView addSubview:toVC.view];
111 | [containView addSubview:imgView0];
112 | [containView addSubview:imgView1];
113 |
114 | toVC.view.hidden = YES;
115 |
116 | switch (type) {
117 | case WXSTransitionAnimationTypeBrickOpenHorizontal:
118 | imgView0.layer.transform = CATransform3DMakeTranslation(-screenWidth/2, 0, 0);
119 | imgView1.layer.transform = CATransform3DMakeTranslation(screenWidth/2, 0, 0);
120 | break;
121 |
122 | default:
123 | imgView0.layer.transform = CATransform3DMakeTranslation(0, -screenHeight/2, 0);
124 | imgView1.layer.transform = CATransform3DMakeTranslation(0, screenHeight/2, 0);
125 | break;
126 | }
127 |
128 | [UIView animateWithDuration:self.animationTime animations:^{
129 | imgView0.layer.transform = CATransform3DIdentity;
130 | imgView1.layer.transform = CATransform3DIdentity;
131 |
132 | } completion:^(BOOL finished) {
133 |
134 | if ([transitionContext transitionWasCancelled]) {
135 | [transitionContext completeTransition:NO];
136 | }else{
137 | [transitionContext completeTransition:YES];
138 | }
139 | toVC.view.hidden = NO;
140 | [imgView0 removeFromSuperview];
141 | [imgView1 removeFromSuperview];
142 |
143 | }];
144 |
145 |
146 | __weak UIViewController *weakToVC = toVC;
147 |
148 | self.willEndInteractiveBlock = ^(BOOL sucess) {
149 | if (sucess) {
150 | weakToVC.view.hidden = NO;
151 |
152 | }else{
153 | weakToVC.view.hidden = YES;
154 | }
155 | [imgView0 removeFromSuperview];
156 | [imgView1 removeFromSuperview];
157 | };
158 |
159 | }
160 |
161 | - (void)brickCloseNextWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext{
162 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
163 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
164 | UIView *containView = [transitionContext containerView];
165 |
166 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
167 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
168 |
169 | CGRect rect0 ;
170 | CGRect rect1 ;
171 |
172 | switch (type) {
173 | case WXSTransitionAnimationTypeBrickCloseHorizontal:
174 | rect0 = CGRectMake(0, 0 , screenWidth/2, screenHeight);
175 | rect1 = CGRectMake(screenWidth/2 , 0 , screenWidth/2, screenHeight);
176 | break;
177 |
178 | default:
179 | rect0 = CGRectMake(0, 0 , screenWidth, screenHeight/2);
180 | rect1 = CGRectMake(0 , screenHeight/2 , screenWidth, screenHeight/2);
181 | break;
182 | }
183 |
184 | UIImage *image0 = [self imageFromView:toVC.view atFrame:rect0];
185 | UIImage *image1 = [self imageFromView:toVC.view atFrame:rect1];
186 |
187 | UIImageView *imgView0 = [[UIImageView alloc] initWithImage:image0];
188 | UIImageView *imgView1 = [[UIImageView alloc] initWithImage:image1];
189 |
190 | [containView addSubview:fromVC.view];
191 | [containView addSubview:toVC.view];
192 | [containView addSubview:imgView0];
193 | [containView addSubview:imgView1];
194 |
195 | toVC.view.hidden = YES;
196 |
197 | switch (type) {
198 | case WXSTransitionAnimationTypeBrickCloseHorizontal:
199 | imgView0.layer.transform = CATransform3DMakeTranslation(-screenWidth/2, 0, 0);
200 | imgView1.layer.transform = CATransform3DMakeTranslation(screenWidth/2, 0, 0);
201 | break;
202 |
203 | default:
204 | imgView0.layer.transform = CATransform3DMakeTranslation(0, -screenHeight/2, 0);
205 | imgView1.layer.transform = CATransform3DMakeTranslation(0, screenHeight/2, 0);
206 | break;
207 | }
208 | [UIView animateWithDuration:self.animationTime animations:^{
209 | imgView0.layer.transform = CATransform3DIdentity;
210 | imgView1.layer.transform = CATransform3DIdentity;
211 |
212 | } completion:^(BOOL finished) {
213 |
214 | if ([transitionContext transitionWasCancelled]) {
215 | [transitionContext completeTransition:NO];
216 | }else{
217 | [transitionContext completeTransition:YES];
218 | toVC.view.hidden = NO;
219 | }
220 | [imgView0 removeFromSuperview];
221 | [imgView1 removeFromSuperview];
222 |
223 | }];
224 |
225 |
226 | }
227 | - (void)brickCloseBackWithType:(WXSTransitionAnimationType)type andTransitionContext:(id)transitionContext{
228 |
229 | __weak UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
230 | __weak UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
231 | UIView *containView = [transitionContext containerView];
232 |
233 |
234 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
235 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
236 |
237 | CGRect rect0 ;
238 | CGRect rect1 ;
239 |
240 | switch (type) {
241 | case WXSTransitionAnimationTypeBrickCloseHorizontal:
242 | rect0 = CGRectMake(0, 0 , screenWidth/2, screenHeight);
243 | rect1 = CGRectMake(screenWidth/2 , 0 , screenWidth/2, screenHeight);
244 | break;
245 |
246 | default:
247 | rect0 = CGRectMake(0, 0 , screenWidth, screenHeight/2);
248 | rect1 = CGRectMake(0 , screenHeight/2 , screenWidth, screenHeight/2);
249 | break;
250 | }
251 |
252 |
253 | UIImage *image0 = [self imageFromView:fromVC.view atFrame:rect0];
254 | UIImage *image1 = [self imageFromView:fromVC.view atFrame:rect1];
255 |
256 | UIImageView *imgView0 = [[UIImageView alloc] initWithImage:image0];
257 | UIImageView *imgView1 = [[UIImageView alloc] initWithImage:image1];
258 |
259 | [containView addSubview:fromVC.view];
260 | [containView addSubview:toVC.view];
261 | [containView addSubview:imgView0];
262 | [containView addSubview:imgView1];
263 |
264 |
265 | [UIView animateWithDuration:self.animationTime animations:^{
266 |
267 | switch (type) {
268 | case WXSTransitionAnimationTypeBrickCloseHorizontal:
269 | imgView0.layer.transform = CATransform3DMakeTranslation(-screenWidth/2, 0, 0);
270 | imgView1.layer.transform = CATransform3DMakeTranslation(screenWidth/2, 0, 0);
271 | break;
272 |
273 | default:
274 | imgView0.layer.transform = CATransform3DMakeTranslation(0, -screenHeight/2, 0);
275 | imgView1.layer.transform = CATransform3DMakeTranslation(0, screenHeight/2, 0);
276 | break;
277 | }
278 |
279 |
280 | } completion:^(BOOL finished) {
281 |
282 | if ([transitionContext transitionWasCancelled]) {
283 | [transitionContext completeTransition:NO];
284 | }else{
285 | [transitionContext completeTransition:YES];
286 |
287 | }
288 | toVC.view.hidden = NO;
289 | [imgView0 removeFromSuperview];
290 | [imgView1 removeFromSuperview];
291 |
292 |
293 | }];
294 |
295 |
296 | __weak UIViewController *weakToVC = toVC;
297 |
298 | self.willEndInteractiveBlock = ^(BOOL sucess) {
299 | if (sucess) {
300 | [imgView0 removeFromSuperview];
301 | [imgView1 removeFromSuperview];
302 |
303 | }else{
304 | weakToVC.view.hidden = YES;
305 | }
306 | [imgView0 removeFromSuperview];
307 | [imgView1 removeFromSuperview];
308 |
309 | };
310 | }
311 |
312 | //- (UIImage *)imageFromView: (UIView *)view atFrame:(CGRect)rect{
313 | //
314 | // UIGraphicsBeginImageContext(view.frame.size);
315 | // CGContextRef context = UIGraphicsGetCurrentContext();
316 | // CGContextSaveGState(context);
317 | // UIRectClip(rect);
318 | // [view.layer renderInContext:context];
319 | // UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
320 | // UIGraphicsEndImageContext();
321 | // return theImage;
322 | //
323 | //}
324 |
325 |
326 | @end
327 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+CoverAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+CoverAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (CoverAnimation)
12 |
13 |
14 | -(void)coverTransitionNextAnimationWithContext:(id)transitionContext;
15 | -(void)coverTransitionBackAnimationWithContext:(id)transitionContext;
16 |
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+CoverAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+CoverAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+CoverAnimation.h"
10 |
11 | @implementation WXSTransitionManager (CoverAnimation)
12 |
13 |
14 |
15 | -(void)coverTransitionNextAnimationWithContext:(id)transitionContext{
16 |
17 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
18 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
19 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
20 | UIView *containView = [transitionContext containerView];
21 |
22 | [containView addSubview:toVC.view];
23 | [containView addSubview:fromVC.view];
24 | [containView addSubview:tempView];
25 |
26 | tempView.layer.transform = CATransform3DMakeScale(4, 4, 1);
27 | tempView.alpha = 0.1;
28 | tempView.hidden = NO;
29 |
30 |
31 | [UIView animateWithDuration:self.animationTime animations:^{
32 |
33 | tempView.layer.transform = CATransform3DIdentity;
34 | tempView.alpha = 1;
35 |
36 | } completion:^(BOOL finished) {
37 |
38 | if ([transitionContext transitionWasCancelled]) {
39 | toVC.view.hidden = YES;
40 | [transitionContext completeTransition:NO];
41 | }else{
42 | toVC.view.hidden = NO;
43 | [transitionContext completeTransition:YES];
44 | }
45 | [tempView removeFromSuperview];
46 |
47 | }];
48 |
49 | }
50 |
51 | -(void)coverTransitionBackAnimationWithContext:(id)transitionContext{
52 |
53 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
54 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
55 |
56 | UIView *tempView = [fromVC.view snapshotViewAfterScreenUpdates:NO];
57 | UIView *containView = [transitionContext containerView];
58 |
59 | [containView addSubview:fromVC.view];
60 | [containView addSubview:toVC.view];
61 | [containView addSubview:tempView];
62 |
63 | fromVC.view.hidden = YES;
64 | toVC.view.hidden = NO;
65 | toVC.view.alpha = 1;
66 | tempView.hidden = NO;
67 | tempView.alpha = 1;
68 |
69 | [UIView animateWithDuration:self.animationTime animations:^{
70 | tempView.layer.transform = CATransform3DMakeScale(4, 4, 1);
71 | tempView.alpha = 0.0;
72 | } completion:^(BOOL finished) {
73 |
74 | if ([transitionContext transitionWasCancelled]) {
75 |
76 | fromVC.view.hidden = NO;
77 | [transitionContext completeTransition:NO];
78 | tempView.alpha = 1;
79 |
80 | }else{
81 | [transitionContext completeTransition:YES];
82 | toVC.view.hidden = NO;
83 |
84 | }
85 | [tempView removeFromSuperview];
86 | }];
87 |
88 | //小心循环引用
89 | __weak UIViewController * weakToVC = toVC;
90 | __weak UIViewController * weakFromVC = fromVC;
91 |
92 | self.willEndInteractiveBlock = ^(BOOL success){
93 |
94 | if (success) {
95 | weakToVC.view.hidden = NO;
96 | [tempView removeFromSuperview];
97 |
98 | }else{
99 | weakFromVC.view.hidden = NO;
100 | tempView.alpha = 1;
101 | }
102 | };
103 | }
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+FlipAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+FlipAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 2017/6/12.
6 | // Copyright © 2017年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (FlipAnimation)
12 |
13 | - (void)tipFlipToNextAnimationContext:(id)transitionContext;
14 | - (void)tipFlipBackAnimationContext:(id)transitionContext;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+FlipAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+FlipAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 2017/6/12.
6 | // Copyright © 2017年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+FlipAnimation.h"
10 |
11 | @implementation WXSTransitionManager (FlipAnimation)
12 | - (void)tipFlipToNextAnimationContext:(id)transitionContext {
13 | [self tipFlipBackAnimationContext:transitionContext];
14 | self.willEndInteractiveBlock = nil;
15 | }
16 | - (void)tipFlipBackAnimationContext:(id)transitionContext {
17 |
18 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
19 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
20 | UIView *containView = [transitionContext containerView];
21 | UIView *fromView = fromVC.view;
22 | UIView *toView = toVC.view;
23 |
24 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
25 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
26 |
27 |
28 | UIImage *topImg = [self imageFromView:toView atFrame:CGRectMake(0, 0, screenWidth, screenHeight/2)];
29 | UIImageView *topView = [[UIImageView alloc] initWithImage:topImg];
30 | [topView setContentMode:UIViewContentModeScaleAspectFill];
31 | topView.layer.transform = CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0);
32 | topView.layer.doubleSided = NO;
33 |
34 | UIImage *fromImgTop = [self imageFromView:fromView atFrame:CGRectMake(0, 0, screenWidth, screenHeight/2)];
35 | UIImageView *fromTopView = [[UIImageView alloc] initWithImage:fromImgTop];
36 | fromTopView.backgroundColor = [UIColor clearColor];
37 | fromTopView.layer.doubleSided = NO;
38 |
39 | UIImage *fromImgBottom = [self imageFromView:fromView atFrame:CGRectMake(0, screenHeight/2, screenWidth, screenHeight/2)];
40 | UIImageView *fromBottomView = [[UIImageView alloc] initWithImage:fromImgBottom];
41 | fromBottomView.layer.doubleSided = NO;
42 |
43 | UIView *flipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
44 | flipView.backgroundColor = [UIColor clearColor];
45 | [flipView.layer addSublayer:topView.layer];
46 | [flipView.layer addSublayer:fromBottomView.layer];
47 |
48 | //addsubView
49 |
50 | [containView addSubview:toView];
51 | [containView addSubview:fromTopView];
52 | [containView addSubview:flipView];
53 |
54 |
55 | [UIView animateWithDuration:self.animationTime animations:^{
56 | fromBottomView.layer.transform = CATransform3DMakeRotation(- M_PI, 1.0, 0.0, 0.0);
57 | topView.layer.transform = CATransform3DIdentity;
58 | } completion:^(BOOL finished) {
59 | [fromTopView removeFromSuperview];
60 | [fromBottomView removeFromSuperview];
61 | [topView removeFromSuperview];
62 | [flipView removeFromSuperview];
63 |
64 | if ([transitionContext transitionWasCancelled]) {
65 | [transitionContext completeTransition:NO];
66 | }else {
67 | [containView bringSubviewToFront:toView];
68 | [transitionContext completeTransition:YES];
69 | }
70 |
71 | }];
72 |
73 | self.willEndInteractiveBlock = ^(BOOL success) {
74 | if (success) {
75 | [fromTopView removeFromSuperview];
76 | [fromBottomView removeFromSuperview];
77 | [topView removeFromSuperview];
78 | [flipView removeFromSuperview];
79 | }
80 | };
81 |
82 | }
83 |
84 |
85 |
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+FragmentAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+FragmentAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (FragmentAnimation)
12 |
13 | -(void)fragmentShowNextType:(WXSTransitionAnimationType)type andContext:(id)transitionContext;
14 | -(void)fragmentShowBackType:(WXSTransitionAnimationType)type andContext:(id)transitionContext;
15 | -(void)fragmentHideNextType:(WXSTransitionAnimationType)type andContext:(id)transitionContext;
16 | -(void)fragmentHideBackType:(WXSTransitionAnimationType)type andContext:(id)transitionContext;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+FragmentAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+FragmentAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+FragmentAnimation.h"
10 |
11 | @implementation WXSTransitionManager (FragmentAnimation)
12 |
13 | -(void)fragmentShowNextType:(WXSTransitionAnimationType)type andContext:(id)transitionContext {
14 |
15 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
16 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
17 | UIView *containerView = [transitionContext containerView];
18 |
19 | UIView *toVCTempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
20 |
21 | [containerView addSubview:toVC.view];
22 | [containerView addSubview:fromVC.view];
23 |
24 | NSMutableArray *fragmentViews = [[NSMutableArray alloc] init];
25 |
26 | CGSize size = fromVC.view.frame.size;
27 | CGFloat fragmentWidth = 20.0f;
28 |
29 | NSInteger rowNum = size.width/fragmentWidth + 1;
30 | for (int i = 0; i < rowNum ; i++) {
31 |
32 | for (int j = 0; j < size.height/fragmentWidth + 1; j++) {
33 |
34 | CGRect rect = CGRectMake(i*fragmentWidth, j*fragmentWidth, fragmentWidth, fragmentWidth);
35 | UIView *fragmentView = [toVCTempView resizableSnapshotViewFromRect:rect afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero];
36 | [containerView addSubview:fragmentView];
37 | [fragmentViews addObject:fragmentView];
38 | fragmentView.frame = rect;
39 | switch (type) {
40 | case WXSTransitionAnimationTypeFragmentShowFromRight:
41 | fragmentView.layer.transform = CATransform3DMakeTranslation( random()%50 *50, 0, 0);
42 |
43 | break;
44 | case WXSTransitionAnimationTypeFragmentShowFromLeft:
45 | fragmentView.layer.transform = CATransform3DMakeTranslation( - random()%50 *50, 0 , 0);
46 |
47 | break;
48 | case WXSTransitionAnimationTypeFragmentShowFromTop:
49 | fragmentView.layer.transform = CATransform3DMakeTranslation(0, - random()%50 *50, 0);
50 |
51 | break;
52 |
53 | default:
54 | fragmentView.layer.transform = CATransform3DMakeTranslation(0, random()%50 *50, 0);
55 |
56 | break;
57 | }
58 | fragmentView.alpha = 0;
59 | }
60 |
61 | }
62 |
63 |
64 | [UIView animateWithDuration:self.animationTime animations:^{
65 | for (UIView *fragmentView in fragmentViews) {
66 | fragmentView.layer.transform = CATransform3DIdentity;
67 | fragmentView.alpha = 1;
68 |
69 | }
70 | } completion:^(BOOL finished) {
71 | for (UIView *fragmentView in fragmentViews) {
72 | [fragmentView removeFromSuperview];
73 | }
74 | if ([transitionContext transitionWasCancelled]) {
75 | [transitionContext completeTransition:NO];
76 | fromVC.view.hidden = NO;
77 | }else{
78 | [transitionContext completeTransition:YES];
79 | fromVC.view.hidden = NO;
80 | }
81 |
82 | }];
83 | }
84 | -(void)fragmentShowBackType:(WXSTransitionAnimationType)type andContext:(id)transitionContext{
85 |
86 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
87 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
88 | UIView *containerView = [transitionContext containerView];
89 | UIView *fromTempView = [fromVC.view snapshotViewAfterScreenUpdates:NO];
90 |
91 | [containerView addSubview:toVC.view];
92 |
93 | NSMutableArray *fragmentViews = [[NSMutableArray alloc] init];
94 |
95 | CGSize size = fromVC.view.frame.size;
96 | CGFloat fragmentWidth = 20.0f;
97 |
98 | NSInteger rowNum = size.width/fragmentWidth + 1;
99 | for (int i = 0; i < rowNum ; i++) {
100 |
101 | for (int j = 0; j < size.height/fragmentWidth + 1; j++) {
102 |
103 | CGRect rect = CGRectMake(i*fragmentWidth, j*fragmentWidth, fragmentWidth, fragmentWidth);
104 | UIView *fragmentView = [fromTempView resizableSnapshotViewFromRect:rect afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero];
105 | [containerView addSubview:fragmentView];
106 | [fragmentViews addObject:fragmentView];
107 | fragmentView.frame = rect;
108 | }
109 |
110 | }
111 |
112 | toVC.view.hidden = NO;
113 | fromVC.view.hidden = YES;
114 |
115 | [UIView animateWithDuration:self.animationTime animations:^{
116 | for (UIView *fragmentView in fragmentViews) {
117 |
118 | CGRect rect = fragmentView.frame;
119 |
120 | switch (type) {
121 | case WXSTransitionAnimationTypeFragmentShowFromRight:
122 | rect.origin.x = rect.origin.x + random()%50 *50;
123 | break;
124 | case WXSTransitionAnimationTypeFragmentShowFromLeft:
125 | rect.origin.x = rect.origin.x - random()%50 *50;
126 |
127 | break;
128 | case WXSTransitionAnimationTypeFragmentShowFromTop:
129 | rect.origin.y = rect.origin.y - random()%50 *50;
130 | break;
131 |
132 | default:
133 | rect.origin.y = rect.origin.y + random()%50 *50;
134 |
135 | break;
136 | }
137 |
138 | fragmentView.frame = rect;
139 | fragmentView.alpha = 0.0;
140 | }
141 | } completion:^(BOOL finished) {
142 | for (UIView *fragmentView in fragmentViews) {
143 | [fragmentView removeFromSuperview];
144 | }
145 | if ([transitionContext transitionWasCancelled]) {
146 | [transitionContext completeTransition:NO];
147 | fromVC.view.hidden = NO;
148 | }else{
149 | [transitionContext completeTransition:YES];
150 | fromVC.view.hidden = NO;
151 | }
152 |
153 | }];
154 |
155 | self.willEndInteractiveBlock = ^(BOOL sucess) {
156 |
157 | if (sucess) {
158 | for (UIView *fragmentView in fragmentViews) {
159 | [fragmentView removeFromSuperview];
160 | }
161 |
162 | }else{
163 | }
164 |
165 | };
166 |
167 |
168 |
169 | }
170 |
171 | -(void)fragmentHideNextType:(WXSTransitionAnimationType)type andContext:(id)transitionContext {
172 |
173 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
174 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
175 | UIView *containerView = [transitionContext containerView];
176 | UIView *fromTempView = [fromVC.view snapshotViewAfterScreenUpdates:NO];
177 |
178 | [containerView addSubview:toVC.view];
179 |
180 | NSMutableArray *fragmentViews = [[NSMutableArray alloc] init];
181 |
182 | CGSize size = fromVC.view.frame.size;
183 | CGFloat fragmentWidth = 20.0f;
184 |
185 | NSInteger rowNum = size.width/fragmentWidth + 1;
186 | for (int i = 0; i < rowNum ; i++) {
187 |
188 | for (int j = 0; j < size.height/fragmentWidth + 1; j++) {
189 |
190 | CGRect rect = CGRectMake(i*fragmentWidth, j*fragmentWidth, fragmentWidth, fragmentWidth);
191 | UIView *fragmentView = [fromTempView resizableSnapshotViewFromRect:rect afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero];
192 | [containerView addSubview:fragmentView];
193 | [fragmentViews addObject:fragmentView];
194 | fragmentView.frame = rect;
195 | }
196 |
197 | }
198 |
199 | toVC.view.hidden = NO;
200 | fromVC.view.hidden = YES;
201 |
202 | [UIView animateWithDuration:self.animationTime animations:^{
203 | for (UIView *fragmentView in fragmentViews) {
204 | CGRect rect = fragmentView.frame;
205 | switch (type) {
206 | case WXSTransitionAnimationTypeFragmentHideFromRight:
207 | rect.origin.x = rect.origin.x - random()%50 *50;
208 | break;
209 | case WXSTransitionAnimationTypeFragmentHideFromLeft:
210 | rect.origin.x = rect.origin.x + random()%50 *50;
211 | break;
212 | case WXSTransitionAnimationTypeFragmentHideFromTop:
213 | rect.origin.y = rect.origin.y + random()%50 *50;
214 | break;
215 | default:
216 | rect.origin.y = rect.origin.y - random()%50 *50;
217 | break;
218 | }
219 | fragmentView.frame = rect;
220 | fragmentView.alpha = 0.0;
221 | }
222 | } completion:^(BOOL finished) {
223 |
224 | for (UIView *fragmentView in fragmentViews) {
225 | [fragmentView removeFromSuperview];
226 | }
227 | if ([transitionContext transitionWasCancelled]) {
228 | [transitionContext completeTransition:NO];
229 | fromVC.view.hidden = NO;
230 | }else{
231 | [transitionContext completeTransition:YES];
232 | fromVC.view.hidden = NO;
233 | }
234 |
235 | }];
236 |
237 | }
238 | -(void)fragmentHideBackType:(WXSTransitionAnimationType)type andContext:(id)transitionContext {
239 |
240 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
241 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
242 | UIView *containerView = [transitionContext containerView];
243 |
244 | [containerView addSubview:toVC.view];
245 |
246 | NSMutableArray *fragmentViews = [[NSMutableArray alloc] init];
247 | CGSize size = fromVC.view.frame.size;
248 | CGFloat fragmentWidth = 20.0f;
249 |
250 | NSInteger rowNum = size.width/fragmentWidth + 1;
251 | for (int i = 0; i < rowNum ; i++) {
252 |
253 | for (int j = 0; j < size.height/fragmentWidth + 1; j++) {
254 |
255 | CGRect rect = CGRectMake(i*fragmentWidth, j*fragmentWidth, fragmentWidth, fragmentWidth);
256 | UIView *fragmentView = [toVC.view resizableSnapshotViewFromRect:rect afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero];
257 | [containerView addSubview:fragmentView];
258 | [fragmentViews addObject:fragmentView];
259 | fragmentView.frame = rect;
260 | switch (type) {
261 | case WXSTransitionAnimationTypeFragmentHideFromRight:
262 | fragmentView.layer.transform = CATransform3DMakeTranslation(-random()%50 *50, 0, 0);
263 | break;
264 | case WXSTransitionAnimationTypeFragmentHideFromLeft:
265 | fragmentView.layer.transform = CATransform3DMakeTranslation(random()%50 *50, 0, 0);
266 | break;
267 | case WXSTransitionAnimationTypeFragmentHideFromTop:
268 | fragmentView.layer.transform = CATransform3DMakeTranslation(0, random()%50 *50, 0);
269 | break;
270 | default:
271 | fragmentView.layer.transform = CATransform3DMakeTranslation(0, -random()%50 *50, 0);
272 | break;
273 | }
274 | fragmentView.alpha = 0;
275 | }
276 |
277 | }
278 |
279 | toVC.view.hidden = YES;
280 | fromVC.view.hidden = NO;
281 |
282 | [UIView animateWithDuration:self.animationTime animations:^{
283 |
284 | for (UIView *fragmentView in fragmentViews) {
285 | fragmentView.alpha = 1;
286 | fragmentView.layer.transform = CATransform3DIdentity;
287 | }
288 | } completion:^(BOOL finished) {
289 | for (UIView *fragmentView in fragmentViews) {
290 | [fragmentView removeFromSuperview];
291 | }
292 | if ([transitionContext transitionWasCancelled]) {
293 | [transitionContext completeTransition:NO];
294 | }else{
295 | [transitionContext completeTransition:YES];
296 | }
297 | toVC.view.hidden = NO;
298 |
299 | }];
300 |
301 | __weak UIViewController * weakToVC = toVC;
302 | self.willEndInteractiveBlock = ^(BOOL sucess) {
303 | if (sucess) {
304 | for (UIView *fragmentView in fragmentViews) {
305 | [fragmentView removeFromSuperview];
306 | }
307 | weakToVC.view.hidden = NO;
308 | }else{
309 |
310 | }
311 | };
312 |
313 | }
314 | @end
315 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+InsideThenPushAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+InsideThenPushAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (InsideThenPushAnimation)
12 | -(void)insideThenPushNextAnimationWithContext:(id)transitionContext;
13 | -(void)insideThenPushBackAnimationWithContext:(id)transitionContext;
14 | @end
15 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+InsideThenPushAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+InsideThenPushAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+InsideThenPushAnimation.h"
10 |
11 | @implementation WXSTransitionManager (InsideThenPushAnimation)
12 |
13 |
14 | -(void)insideThenPushNextAnimationWithContext:(id)transitionContext{
15 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
16 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
17 | UIView *containerView = [transitionContext containerView];
18 |
19 | UIView *fromView = fromVC.view;
20 | UIView *toView = toVC.view;
21 | [containerView addSubview:fromView];
22 | [containerView addSubview:toView];
23 |
24 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
25 |
26 | toView.layer.transform = CATransform3DMakeTranslation(screenWidth,0,0);
27 | [UIView animateWithDuration:self.animationTime animations:^{
28 |
29 | fromView.layer.transform = CATransform3DMakeScale(0.95,0.95,1);
30 | toView.layer.transform = CATransform3DIdentity;
31 |
32 | } completion:^(BOOL finished){
33 |
34 | if ([transitionContext transitionWasCancelled]) {
35 | [transitionContext completeTransition:NO];
36 | fromView.layer.transform = CATransform3DIdentity;
37 |
38 | }else{
39 | [transitionContext completeTransition:YES];
40 | fromView.layer.transform = CATransform3DIdentity;
41 | }
42 | }];
43 | }
44 |
45 | -(void)insideThenPushBackAnimationWithContext:(id)transitionContext{
46 |
47 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
48 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
49 | UIView *containerView = [transitionContext containerView];
50 |
51 | UIView *tempToView = [toVC.view snapshotViewAfterScreenUpdates:YES];
52 | UIView *tempFromView = [fromVC.view snapshotViewAfterScreenUpdates:YES];
53 |
54 | UIView *fromView = fromVC.view;
55 | UIView *toView = toVC.view;
56 |
57 | [containerView addSubview:toView];
58 | [containerView addSubview:fromView];
59 |
60 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
61 | toView.layer.transform = CATransform3DMakeScale(0.95,0.95,1);
62 | fromView.layer.transform = CATransform3DIdentity;
63 | [UIView animateWithDuration:self.animationTime animations:^{
64 | toView.layer.transform = CATransform3DIdentity;
65 | fromView.layer.transform = CATransform3DMakeTranslation(screenWidth,0,0);
66 |
67 | } completion:^(BOOL finished){
68 |
69 | [tempToView removeFromSuperview];
70 | toView.hidden = NO;
71 | [tempFromView removeFromSuperview];
72 | toView.layer.transform = CATransform3DIdentity;
73 | if ([transitionContext transitionWasCancelled]) {
74 | [transitionContext completeTransition:NO];
75 | }else{
76 | [transitionContext completeTransition:YES];
77 | }
78 | }];
79 |
80 | self.willEndInteractiveBlock = ^(BOOL success) {
81 |
82 | if (success) {
83 | toView.layer.transform = CATransform3DIdentity;
84 | fromView.hidden = YES;
85 | [containerView addSubview:tempToView];
86 | }else {
87 | fromView.hidden = NO;
88 | toView.layer.transform = CATransform3DIdentity;
89 |
90 | [tempToView removeFromSuperview];
91 | [containerView addSubview:tempFromView];
92 |
93 |
94 | }
95 |
96 | };
97 |
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+PageAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+PageAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (PageAnimation)
12 |
13 |
14 | -(void)pageTransitionNextAnimationWithContext:(id)transitionContext;
15 | -(void)pageTransitionBackAnimationWithContext:(id)transitionContext;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+PageAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+PageAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+PageAnimation.h"
10 |
11 | @implementation WXSTransitionManager (PageAnimation)
12 |
13 |
14 |
15 | -(void)pageTransitionNextAnimationWithContext:(id)transitionContext {
16 |
17 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
18 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
19 | UIView *tempView = [fromVC.view snapshotViewAfterScreenUpdates:NO];
20 | UIView *containerView = [transitionContext containerView];
21 |
22 | [containerView addSubview:toVC.view];
23 | [containerView addSubview:tempView];
24 | [containerView insertSubview:toVC.view atIndex:0];
25 |
26 | tempView.frame = fromVC.view.frame;
27 | fromVC.view.hidden = YES;
28 | CGPoint point = CGPointMake(0, 0.5);
29 | tempView.frame = CGRectOffset(tempView.frame, (point.x - tempView.layer.anchorPoint.x) * tempView.frame.size.width, (point.y - tempView.layer.anchorPoint.y) * tempView.frame.size.height);
30 | tempView.layer.anchorPoint = point;
31 | CATransform3D transfrom3d = CATransform3DIdentity;
32 | transfrom3d.m34 = -0.002;
33 | containerView.layer.sublayerTransform = transfrom3d;
34 |
35 | [UIView animateWithDuration:self.animationTime animations:^{
36 | tempView.layer.transform = CATransform3DMakeRotation(-M_PI_2, 0, 1, 0);
37 |
38 | } completion:^(BOOL finished) {
39 |
40 | if ([transitionContext transitionWasCancelled]) {
41 | [tempView removeFromSuperview];
42 |
43 | [transitionContext completeTransition:NO];
44 | }else{
45 | [transitionContext completeTransition:YES];
46 | }
47 | fromVC.view.hidden = NO;
48 | }];
49 |
50 | }
51 | -(void)pageTransitionBackAnimationWithContext:(id)transitionContext {
52 |
53 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
54 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
55 |
56 | UIView *containerView = [transitionContext containerView];
57 | UIView *tempView = containerView.subviews.lastObject;
58 | tempView.hidden = NO;
59 | [containerView addSubview:toVC.view];
60 |
61 | toVC.view.hidden = YES;
62 |
63 | [UIView animateWithDuration:self.animationTime animations:^{
64 | tempView.layer.transform = CATransform3DIdentity;
65 | fromVC.view.alpha = 0.2;
66 |
67 | } completion:^(BOOL finished) {
68 | if ([transitionContext transitionWasCancelled]) {
69 | fromVC.view.alpha = 1;
70 | [transitionContext completeTransition:NO];
71 | }else{
72 | [transitionContext completeTransition:YES];
73 | [tempView removeFromSuperview];
74 | toVC.view.hidden = NO;
75 | toVC.view.alpha = 1;
76 | }
77 | }];
78 |
79 | __weak UIViewController * weakToVC = toVC;
80 | __weak UIViewController * weakFromVC = fromVC;
81 | self.willEndInteractiveBlock = ^(BOOL success) {
82 | if (success) {
83 | weakToVC.view.hidden = NO;
84 | weakToVC.view.alpha = 1;
85 | }else{
86 | tempView.hidden = YES;
87 | weakFromVC.view.alpha = 1;
88 | }
89 | };
90 |
91 | }
92 |
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+SpreadAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+SpreadAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/21.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (SpreadAnimation)
12 | - (void)spreadNextWithType:(WXSTransitionAnimationType)type andTransitonContext:(id)transitionContext;
13 | - (void)spreadBackWithType:(WXSTransitionAnimationType)type andTransitonContext:(id)transitionContext;
14 | - (void)pointSpreadNextWithContext:(id)transitionContext;
15 | - (void)pointSpreadBackWithContext:(id)transitionContext;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+SpreadAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+SpreadAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/21.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+SpreadAnimation.h"
10 |
11 | @implementation WXSTransitionManager (SpreadAnimation)
12 |
13 |
14 | - (void)spreadNextWithType:(WXSTransitionAnimationType)type andTransitonContext:(id)transitionContext {
15 |
16 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
17 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
18 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
19 | UIView *containerView = [transitionContext containerView];
20 |
21 | [containerView addSubview:toVC.view];
22 | [containerView addSubview:fromVC.view];
23 | [containerView addSubview:tempView];
24 |
25 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
26 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
27 |
28 |
29 | CGRect rect0 ;
30 | CGRect rect1 = CGRectMake(0, 0, screenWidth, screenHeight);
31 | switch (type) {
32 | case WXSTransitionAnimationTypeSpreadFromRight:
33 | rect0 = CGRectMake(screenWidth, 0, 2, screenHeight);
34 | break;
35 | case WXSTransitionAnimationTypeSpreadFromLeft:
36 | rect0 = CGRectMake(0, 0, 2, screenHeight);
37 | break;
38 | case WXSTransitionAnimationTypeSpreadFromTop:
39 | rect0 = CGRectMake(0, 0, screenWidth, 2);
40 | break;
41 | default:
42 | rect0 = CGRectMake(0, screenHeight , screenWidth, 2);
43 | break;
44 | }
45 |
46 |
47 | UIBezierPath *startPath = [UIBezierPath bezierPathWithRect:rect0];
48 | UIBezierPath *endPath =[UIBezierPath bezierPathWithRect:rect1];
49 |
50 | CAShapeLayer *maskLayer = [CAShapeLayer layer];
51 | maskLayer.path = endPath.CGPath; //动画结束后的值
52 | tempView.layer.mask = maskLayer;
53 |
54 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
55 | animation.fromValue = (__bridge id)(startPath.CGPath);
56 | animation.toValue = (__bridge id)((endPath.CGPath));
57 | animation.duration = self.animationTime;
58 | animation.delegate = self;
59 | [maskLayer addAnimation:animation forKey:@"NextPath"];
60 |
61 | self.completionBlock = ^(){
62 |
63 | if ([transitionContext transitionWasCancelled]) {
64 | [transitionContext completeTransition:NO];
65 | }else{
66 |
67 | [transitionContext completeTransition:YES];
68 | }
69 | [tempView removeFromSuperview];
70 | };
71 |
72 | }
73 | - (void)spreadBackWithType:(WXSTransitionAnimationType)type andTransitonContext:(id)transitionContext {
74 |
75 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
76 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
77 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
78 | UIView *containerView = [transitionContext containerView];
79 |
80 | [containerView addSubview:toVC.view];
81 | [containerView addSubview:fromVC.view];
82 | [containerView addSubview:tempView];
83 |
84 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
85 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
86 |
87 | CGRect rect0 ;
88 | CGRect rect1 = CGRectMake(0, 0, screenWidth, screenHeight);
89 |
90 |
91 | switch (type) {
92 | case WXSTransitionAnimationTypeSpreadFromRight:
93 | rect0 = CGRectMake(0, 0, 2, screenHeight);
94 | break;
95 | case WXSTransitionAnimationTypeSpreadFromLeft:
96 | rect0 = CGRectMake(screenWidth-2, 0, 2, screenHeight);
97 | break;
98 | case WXSTransitionAnimationTypeSpreadFromTop:
99 | rect0 = CGRectMake(0, screenHeight - 2 , screenWidth, 2);
100 | break;
101 |
102 | default:
103 | rect0 = CGRectMake(0, 0, screenWidth, 2);
104 | break;
105 | }
106 |
107 | UIBezierPath *startPath = [UIBezierPath bezierPathWithRect:rect0];
108 | UIBezierPath *endPath =[UIBezierPath bezierPathWithRect:rect1];
109 |
110 | CAShapeLayer *maskLayer = [CAShapeLayer layer];
111 | tempView.layer.mask = maskLayer;
112 | maskLayer.path = endPath.CGPath;
113 |
114 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
115 | animation.delegate = self;
116 | animation.fromValue = (__bridge id)(startPath.CGPath);
117 | animation.toValue = (__bridge id)((endPath.CGPath));
118 | animation.duration = self.animationTime;
119 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
120 | [maskLayer addAnimation:animation forKey:@"BackPath"];
121 |
122 |
123 | __weak UIViewController * weakToVC = toVC;
124 |
125 | self.willEndInteractiveBlock = ^(BOOL success) {
126 |
127 | if (success) {
128 | maskLayer.path = endPath.CGPath;
129 |
130 | }else{
131 | maskLayer.path = startPath.CGPath;
132 | }
133 |
134 | };
135 |
136 | self.completionBlock = ^(){
137 |
138 | [tempView removeFromSuperview];
139 |
140 | if ([transitionContext transitionWasCancelled]) {
141 | [transitionContext completeTransition:NO];
142 |
143 | }else{
144 | [transitionContext completeTransition:YES];
145 | weakToVC.view.hidden = NO;
146 | }
147 |
148 | };
149 |
150 | }
151 |
152 | - (void)pointSpreadNextWithContext:(id)transitionContext{
153 |
154 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
155 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
156 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
157 | UIView *containerView = [transitionContext containerView];
158 |
159 | [containerView addSubview:toVC.view];
160 | [containerView addSubview:fromVC.view];
161 | [containerView addSubview:tempView];
162 |
163 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
164 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
165 |
166 |
167 | CGRect rect = CGRectMake(containerView.center.x - 1, containerView.center.y - 1, 2, 2);
168 | if (self.startView) {
169 | CGPoint tempCenter = [self.startView convertPoint:self.startView.center toView:containerView];
170 | rect = CGRectMake(tempCenter.x - 1, tempCenter.y - 1, 2, 2);
171 | }
172 |
173 | UIBezierPath *startPath = [UIBezierPath bezierPathWithOvalInRect:rect];
174 | UIBezierPath *endPath = [UIBezierPath bezierPathWithArcCenter:containerView.center radius:sqrt(screenHeight * screenHeight + screenWidth * screenWidth) startAngle:0 endAngle:M_PI*2 clockwise:YES];
175 |
176 | CAShapeLayer *maskLayer = [CAShapeLayer layer];
177 | maskLayer.path = endPath.CGPath;
178 | tempView.layer.mask = maskLayer;
179 |
180 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
181 | animation.delegate = self;
182 |
183 | animation.fromValue = (__bridge id)(startPath.CGPath);
184 | animation.toValue = (__bridge id)((endPath.CGPath));
185 | animation.duration = self.animationTime;
186 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
187 | [maskLayer addAnimation:animation forKey:@"PointNextPath"];
188 |
189 | self.completionBlock = ^(){
190 |
191 | if ([transitionContext transitionWasCancelled]) {
192 | [transitionContext completeTransition:NO];
193 | [tempView removeFromSuperview];
194 | }else{
195 | [transitionContext completeTransition:YES];
196 | toVC.view.hidden = NO;
197 | [tempView removeFromSuperview];
198 | }
199 |
200 | };
201 | }
202 | - (void)pointSpreadBackWithContext:(id)transitionContext{
203 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
204 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
205 | UIView *containerView = [transitionContext containerView];
206 | UIView *tempView = [fromVC.view snapshotViewAfterScreenUpdates:NO]; //YES会导致闪一下
207 |
208 | [containerView addSubview:toVC.view];
209 | [containerView addSubview:tempView];
210 |
211 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
212 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
213 |
214 |
215 | CGRect rect = CGRectMake(containerView.center.x-1, containerView.center.y-1, 2, 2);
216 | if (self.startView) {
217 | CGPoint tempCenter = [self.startView convertPoint:self.startView.center toView:containerView];
218 | rect = CGRectMake(tempCenter.x - 1, tempCenter.y - 1, 2, 2);
219 | }
220 |
221 | UIBezierPath *startPath = [UIBezierPath bezierPathWithArcCenter:containerView.center radius:sqrt(screenHeight * screenHeight + screenWidth * screenWidth)/2 startAngle:0 endAngle:M_PI*2 clockwise:YES];
222 | UIBezierPath *endPath = [UIBezierPath bezierPathWithOvalInRect:rect];
223 |
224 | CAShapeLayer *maskLayer = [CAShapeLayer layer];
225 | maskLayer.path = endPath.CGPath;
226 | tempView.layer.mask = maskLayer;
227 |
228 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
229 | animation.delegate = self;
230 | animation.fromValue = (__bridge id)(startPath.CGPath);
231 | animation.toValue = (__bridge id)((endPath.CGPath));
232 | animation.duration = self.animationTime;
233 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
234 | [maskLayer addAnimation:animation forKey:@"PointBackPath"];
235 |
236 | self.willEndInteractiveBlock = ^(BOOL sucess) {
237 | if (sucess) {
238 | maskLayer.path = endPath.CGPath;
239 | }else{
240 | maskLayer.path = startPath.CGPath;
241 | }
242 | };
243 |
244 | self.completionBlock = ^(){
245 |
246 | if ([transitionContext transitionWasCancelled]) {
247 | [transitionContext completeTransition:NO];
248 | }else{
249 |
250 | [transitionContext completeTransition:YES];
251 | toVC.view.hidden = NO;
252 | }
253 | [tempView removeFromSuperview];
254 |
255 | };
256 |
257 | }
258 |
259 | @end
260 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+SystermAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+SystermAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (SystermAnimation)
12 |
13 | -(void)sysTransitionNextAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext;
14 | -(void)sysTransitionBackAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+SystermAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+SystermAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+SystermAnimation.h"
10 | #import "WXSTransitionManager+TypeTool.h"
11 |
12 |
13 |
14 | @implementation WXSTransitionManager (SystermAnimation)
15 |
16 |
17 |
18 | -(void)sysTransitionNextAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext {
19 |
20 |
21 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
22 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
23 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
24 | UIView *temView1 = [fromVC.view snapshotViewAfterScreenUpdates:YES];
25 | UIView *containerView = [transitionContext containerView];
26 |
27 | [containerView addSubview:fromVC.view];
28 | [containerView addSubview:toVC.view];
29 |
30 | [containerView bringSubviewToFront:fromVC.view];
31 | [containerView bringSubviewToFront:toVC.view];
32 |
33 | CATransition *tranAnimation = [self getSysTransitionWithType:type];
34 | [containerView.layer addAnimation:tranAnimation forKey:nil];
35 |
36 | self.completionBlock = ^(){
37 |
38 | if ([transitionContext transitionWasCancelled]) {
39 | [transitionContext completeTransition:NO];
40 | }else{
41 | [transitionContext completeTransition:YES];
42 | toVC.view.hidden = NO;
43 | }
44 | [tempView removeFromSuperview];
45 | [temView1 removeFromSuperview];
46 |
47 | };
48 |
49 | }
50 |
51 | -(void)sysTransitionBackAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext {
52 |
53 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
54 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
55 | UIView *tempView = [toVC.view snapshotViewAfterScreenUpdates:YES];
56 | UIView *temView1 = [fromVC.view snapshotViewAfterScreenUpdates:YES];
57 | UIView *containerView = [transitionContext containerView];
58 |
59 | [containerView addSubview:fromVC.view];
60 | [containerView addSubview:toVC.view];
61 |
62 | CATransition *tranAnimation = [self getSysTransitionWithType:type];
63 | [containerView.layer addAnimation:tranAnimation forKey:nil];
64 |
65 |
66 |
67 | __weak UIViewController * weakToVC = toVC;
68 | self.completionBlock = ^(){
69 |
70 | if ([transitionContext transitionWasCancelled]) {
71 | [transitionContext completeTransition:NO];
72 | }else{
73 | [transitionContext completeTransition:YES];
74 | }
75 | weakToVC.view.hidden = NO;
76 |
77 | [tempView removeFromSuperview];
78 | [temView1 removeFromSuperview];
79 | };
80 |
81 |
82 | self.willEndInteractiveBlock = ^(BOOL success) {
83 | if (success) {
84 | weakToVC.view.hidden = NO;
85 | }else{
86 | weakToVC.view.hidden = YES;
87 | [tempView removeFromSuperview];
88 | [temView1 removeFromSuperview];
89 | }
90 |
91 | };
92 |
93 | }
94 |
95 | @end
96 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+TypeTool.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+TypeTool.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (TypeTool)
12 | -(void)backAnimationTypeFromAnimationType:(WXSTransitionAnimationType)type;
13 | -(CATransition *)getSysTransitionWithType:(WXSTransitionAnimationType )type;
14 | @end
15 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+TypeTool.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+TypeTool.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/20.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+TypeTool.h"
10 |
11 | @implementation WXSTransitionManager (TypeTool)
12 |
13 |
14 | -(void)backAnimationTypeFromAnimationType:(WXSTransitionAnimationType)type{
15 |
16 | switch (type) {
17 | case WXSTransitionAnimationTypeSysFade:{
18 | self.backAnimationType = WXSTransitionAnimationTypeSysFade;
19 | }
20 | break;
21 | case WXSTransitionAnimationTypeSysPushFromRight:{
22 | self.backAnimationType = WXSTransitionAnimationTypeSysPushFromLeft;
23 | }
24 | break;
25 | case WXSTransitionAnimationTypeSysPushFromLeft:{
26 | self.backAnimationType = WXSTransitionAnimationTypeSysPushFromRight;
27 | }
28 | break;
29 | case WXSTransitionAnimationTypeSysPushFromTop:{
30 | self.backAnimationType = WXSTransitionAnimationTypeSysPushFromBottom;
31 | }
32 | break;
33 | case WXSTransitionAnimationTypeSysPushFromBottom:{
34 | self.backAnimationType = WXSTransitionAnimationTypeSysPushFromTop;
35 | }
36 | break;
37 | case WXSTransitionAnimationTypeSysRevealFromRight:{
38 | self.backAnimationType = WXSTransitionAnimationTypeSysMoveInFromLeft;
39 | }
40 | break;
41 | case WXSTransitionAnimationTypeSysRevealFromLeft:{
42 | self.backAnimationType = WXSTransitionAnimationTypeSysMoveInFromRight;
43 | }
44 | break;
45 | case WXSTransitionAnimationTypeSysRevealFromTop:{
46 | self.backAnimationType = WXSTransitionAnimationTypeSysMoveInFromBottom;
47 | }
48 | break;
49 | case WXSTransitionAnimationTypeSysRevealFromBottom:{
50 | self.backAnimationType = WXSTransitionAnimationTypeSysMoveInFromTop;
51 | }
52 | break;
53 | case WXSTransitionAnimationTypeSysMoveInFromRight:{
54 | self.backAnimationType = WXSTransitionAnimationTypeSysRevealFromLeft;
55 | }
56 | break;
57 | case WXSTransitionAnimationTypeSysMoveInFromLeft:{
58 | self.backAnimationType = WXSTransitionAnimationTypeSysRevealFromRight;
59 |
60 | }
61 | break;
62 | case WXSTransitionAnimationTypeSysMoveInFromTop:{
63 | self.backAnimationType = WXSTransitionAnimationTypeSysRevealFromBottom;
64 | }
65 | break;
66 | case WXSTransitionAnimationTypeSysMoveInFromBottom:{
67 | self.backAnimationType = WXSTransitionAnimationTypeSysRevealFromTop;
68 | }
69 | break;
70 | case WXSTransitionAnimationTypeSysCubeFromRight:{
71 | self.backAnimationType = WXSTransitionAnimationTypeSysCubeFromLeft;
72 | }
73 | break;
74 | case WXSTransitionAnimationTypeSysCubeFromLeft:{
75 | self.backAnimationType = WXSTransitionAnimationTypeSysCubeFromRight;
76 | }
77 | break;
78 | case WXSTransitionAnimationTypeSysCubeFromTop:{
79 | self.backAnimationType = WXSTransitionAnimationTypeSysCubeFromBottom;
80 | }
81 | break;
82 | case WXSTransitionAnimationTypeSysCubeFromBottom:{
83 | self.backAnimationType = WXSTransitionAnimationTypeSysCubeFromTop;
84 |
85 | }
86 | break;
87 | case WXSTransitionAnimationTypeSysSuckEffect:{
88 | self.backAnimationType = WXSTransitionAnimationTypeSysSuckEffect;
89 | }
90 | break;
91 | case WXSTransitionAnimationTypeSysOglFlipFromRight:{
92 | self.backAnimationType = WXSTransitionAnimationTypeSysOglFlipFromLeft;
93 | }
94 | break;
95 | case WXSTransitionAnimationTypeSysOglFlipFromLeft:{
96 | self.backAnimationType = WXSTransitionAnimationTypeSysOglFlipFromRight;
97 | }
98 | break;
99 | case WXSTransitionAnimationTypeSysOglFlipFromTop:{
100 | self.backAnimationType = WXSTransitionAnimationTypeSysOglFlipFromBottom;
101 | }
102 | break;
103 | case WXSTransitionAnimationTypeSysOglFlipFromBottom:{
104 | self.backAnimationType = WXSTransitionAnimationTypeSysOglFlipFromTop;
105 | }
106 | break;
107 | case WXSTransitionAnimationTypeSysRippleEffect:{
108 | self.backAnimationType = WXSTransitionAnimationTypeSysRippleEffect;
109 | }
110 | break;
111 | case WXSTransitionAnimationTypeSysPageCurlFromRight:{
112 | self.backAnimationType = WXSTransitionAnimationTypeSysPageUnCurlFromRight;
113 | }
114 | break;
115 | case WXSTransitionAnimationTypeSysPageCurlFromLeft:{
116 | self.backAnimationType = WXSTransitionAnimationTypeSysPageUnCurlFromLeft;
117 | }
118 | break;
119 | case WXSTransitionAnimationTypeSysPageCurlFromTop:{
120 | self.backAnimationType = WXSTransitionAnimationTypeSysPageUnCurlFromBottom;
121 | }
122 | break;
123 | case WXSTransitionAnimationTypeSysPageCurlFromBottom:{
124 | self.backAnimationType = WXSTransitionAnimationTypeSysPageUnCurlFromTop;
125 | }
126 | break;
127 | case WXSTransitionAnimationTypeSysPageUnCurlFromRight:{
128 | self.backAnimationType = WXSTransitionAnimationTypeSysPageCurlFromRight;
129 | }
130 | break;
131 | case WXSTransitionAnimationTypeSysPageUnCurlFromLeft:{
132 | self.backAnimationType = WXSTransitionAnimationTypeSysPageCurlFromLeft;
133 | }
134 | break;
135 | case WXSTransitionAnimationTypeSysPageUnCurlFromTop:{
136 | self.backAnimationType = WXSTransitionAnimationTypeSysPageCurlFromBottom;
137 | }
138 | break;
139 | case WXSTransitionAnimationTypeSysPageUnCurlFromBottom:{
140 | self.backAnimationType = WXSTransitionAnimationTypeSysPageCurlFromTop;
141 | }
142 | break;
143 | case WXSTransitionAnimationTypeSysCameraIrisHollowOpen:{
144 | self.backAnimationType = WXSTransitionAnimationTypeSysCameraIrisHollowClose;
145 | }
146 | break;
147 | case WXSTransitionAnimationTypeSysCameraIrisHollowClose:{
148 | self.backAnimationType = WXSTransitionAnimationTypeSysCameraIrisHollowOpen;
149 |
150 | }
151 | break;
152 | default:
153 | break;
154 | }
155 | }
156 |
157 | -(CATransition *)getSysTransitionWithType:(WXSTransitionAnimationType )type{
158 |
159 | CATransition *tranAnimation=[CATransition animation];
160 | tranAnimation.duration= self.animationTime;
161 | tranAnimation.delegate = self;
162 | switch (type) {
163 | case WXSTransitionAnimationTypeSysFade:{
164 | tranAnimation.type=kCATransitionFade;
165 | }
166 | break;
167 | case WXSTransitionAnimationTypeSysPushFromRight:{
168 | tranAnimation.type = kCATransitionPush;
169 | tranAnimation.subtype=kCATransitionFromRight;
170 | }
171 | break;
172 | case WXSTransitionAnimationTypeSysPushFromLeft:{
173 | tranAnimation.type = kCATransitionPush;
174 | tranAnimation.subtype=kCATransitionFromLeft;
175 | }
176 | break;
177 | case WXSTransitionAnimationTypeSysPushFromTop:{
178 | tranAnimation.type = kCATransitionPush;
179 | tranAnimation.subtype=kCATransitionFromTop;
180 | }
181 | break;
182 | case WXSTransitionAnimationTypeSysPushFromBottom:{
183 | tranAnimation.type = kCATransitionPush;
184 | tranAnimation.subtype=kCATransitionFromBottom;
185 |
186 | }
187 | break;
188 | case WXSTransitionAnimationTypeSysRevealFromRight:{
189 | tranAnimation.type = kCATransitionReveal;
190 | tranAnimation.subtype=kCATransitionFromRight;
191 | }
192 | break;
193 | case WXSTransitionAnimationTypeSysRevealFromLeft:{
194 | tranAnimation.type = kCATransitionReveal;
195 | tranAnimation.subtype=kCATransitionFromLeft;
196 | }
197 | break;
198 | case WXSTransitionAnimationTypeSysRevealFromTop:{
199 | tranAnimation.type = kCATransitionReveal;
200 | tranAnimation.subtype=kCATransitionFromTop;
201 | }
202 | break;
203 | case WXSTransitionAnimationTypeSysRevealFromBottom:{
204 | tranAnimation.type = kCATransitionReveal;
205 | tranAnimation.subtype=kCATransitionFromBottom;
206 | }
207 | break;
208 | case WXSTransitionAnimationTypeSysMoveInFromRight:{
209 | tranAnimation.type = kCATransitionMoveIn;
210 | tranAnimation.subtype=kCATransitionFromRight;
211 | }
212 | break;
213 | case WXSTransitionAnimationTypeSysMoveInFromLeft:{
214 | tranAnimation.type = kCATransitionMoveIn;
215 | tranAnimation.subtype=kCATransitionFromLeft;
216 | }
217 | break;
218 | case WXSTransitionAnimationTypeSysMoveInFromTop:{
219 | tranAnimation.type = kCATransitionMoveIn;
220 | tranAnimation.subtype=kCATransitionFromTop;
221 | }
222 | break;
223 | case WXSTransitionAnimationTypeSysMoveInFromBottom:{
224 | tranAnimation.type = kCATransitionMoveIn;
225 | tranAnimation.subtype=kCATransitionFromBottom;
226 | }
227 | break;
228 | case WXSTransitionAnimationTypeSysCubeFromRight:{
229 | tranAnimation.type = @"cube";
230 | tranAnimation.subtype=kCATransitionFromRight;
231 | }
232 | break;
233 | case WXSTransitionAnimationTypeSysCubeFromLeft:{
234 | tranAnimation.type = @"cube";
235 | tranAnimation.subtype=kCATransitionFromLeft;
236 | }
237 | break;
238 | case WXSTransitionAnimationTypeSysCubeFromTop:{
239 | tranAnimation.type=@"cube";
240 | tranAnimation.subtype=kCATransitionFromTop;
241 | }
242 | break;
243 | case WXSTransitionAnimationTypeSysCubeFromBottom:{
244 | tranAnimation.type=@"cube";
245 | tranAnimation.subtype=kCATransitionFromBottom;
246 | }
247 | break;
248 | case WXSTransitionAnimationTypeSysSuckEffect:{
249 | tranAnimation.type=@"suckEffect";
250 | }
251 | break;
252 | case WXSTransitionAnimationTypeSysOglFlipFromRight:{
253 | tranAnimation.type=@"oglFlip";
254 | tranAnimation.subtype=kCATransitionFromRight;
255 | }
256 | break;
257 | case WXSTransitionAnimationTypeSysOglFlipFromLeft:{
258 | tranAnimation.type=@"oglFlip";
259 | tranAnimation.subtype=kCATransitionFromLeft;
260 | }
261 | break;
262 | case WXSTransitionAnimationTypeSysOglFlipFromTop:{
263 | tranAnimation.type=@"oglFlip";
264 | tranAnimation.subtype=kCATransitionFromTop;
265 | }
266 | break;
267 | case WXSTransitionAnimationTypeSysOglFlipFromBottom:{
268 | tranAnimation.type=@"oglFlip";
269 | tranAnimation.subtype=kCATransitionFromBottom;
270 | }
271 | break;
272 | case WXSTransitionAnimationTypeSysRippleEffect:{
273 | tranAnimation.type=@"rippleEffect";
274 | }
275 | break;
276 | case WXSTransitionAnimationTypeSysPageCurlFromRight:{
277 | tranAnimation.type=@"pageCurl";
278 | tranAnimation.subtype=kCATransitionFromRight;
279 | }
280 | break;
281 | case WXSTransitionAnimationTypeSysPageCurlFromLeft:{
282 | tranAnimation.type=@"pageCurl";
283 | tranAnimation.subtype=kCATransitionFromLeft;
284 | }
285 | break;
286 | case WXSTransitionAnimationTypeSysPageCurlFromTop:{
287 | tranAnimation.type=@"pageCurl";
288 | tranAnimation.subtype=kCATransitionFromTop;
289 | }
290 | break;
291 | case WXSTransitionAnimationTypeSysPageCurlFromBottom:{
292 | tranAnimation.type=@"pageCurl";
293 | tranAnimation.subtype=kCATransitionFromBottom;
294 | }
295 | break;
296 | case WXSTransitionAnimationTypeSysPageUnCurlFromRight:{
297 | tranAnimation.type=@"pageUnCurl";
298 | tranAnimation.subtype=kCATransitionFromRight;
299 | }
300 | break;
301 | case WXSTransitionAnimationTypeSysPageUnCurlFromLeft:{
302 | tranAnimation.type=@"pageUnCurl";
303 | tranAnimation.subtype=kCATransitionFromLeft;
304 | }
305 | break;
306 | case WXSTransitionAnimationTypeSysPageUnCurlFromTop:{
307 | tranAnimation.type=@"pageUnCurl";
308 | tranAnimation.subtype=kCATransitionFromTop;
309 | }
310 | break;
311 | case WXSTransitionAnimationTypeSysPageUnCurlFromBottom:{
312 | tranAnimation.type=@"pageUnCurl";
313 | tranAnimation.subtype=kCATransitionFromBottom;
314 | }
315 | break;
316 | case WXSTransitionAnimationTypeSysCameraIrisHollowOpen:{
317 | tranAnimation.type=@"cameraIrisHollowOpen";
318 | }
319 | break;
320 | case WXSTransitionAnimationTypeSysCameraIrisHollowClose:{
321 | tranAnimation.type=@"cameraIrisHollowClose";
322 | }
323 | break;
324 | default:
325 | break;
326 | }
327 | return tranAnimation;
328 | }
329 | @end
330 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+ViewMoveAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+ViewMoveAnimation.h
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager.h"
10 |
11 | @interface WXSTransitionManager (ViewMoveAnimation)
12 | - (void)viewMoveNextWithType:(WXSTransitionAnimationType )type andContext:(id)transitionContext;
13 | - (void)viewMoveBackWithType:(WXSTransitionAnimationType )type andContext:(id)transitionContext;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager+ViewMoveAnimation.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionManager+ViewMoveAnimation.m
3 | // WXSTransition
4 | //
5 | // Created by AlanWang on 16/9/22.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionManager+ViewMoveAnimation.h"
10 |
11 | @implementation WXSTransitionManager (ViewMoveAnimation)
12 |
13 |
14 | - (void)viewMoveRollNextWithType:(WXSTransitionAnimationType )type andContext:(id)transitionContext {
15 |
16 |
17 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
18 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
19 | UIView *startView = [self.startView snapshotViewAfterScreenUpdates:NO];
20 | UIView *containerView = [transitionContext containerView];
21 |
22 | [containerView addSubview:toVC.view];
23 | [containerView addSubview:startView];
24 |
25 | startView.frame = [self.startView convertRect:self.startView.bounds toView: containerView];
26 | toVC.view.alpha = 0;
27 | self.startView.hidden = YES;
28 | self.targetView.hidden = YES;
29 | fromVC.view.alpha = 1;
30 | }
31 |
32 |
33 | - (void)viewMoveNextWithType:(WXSTransitionAnimationType )type andContext:(id)transitionContext{
34 |
35 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
36 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
37 | UIView *startView = [self.startView snapshotViewAfterScreenUpdates:NO];
38 | UIView *containerView = [transitionContext containerView];
39 |
40 | [containerView addSubview:toVC.view];
41 | [containerView addSubview:startView];
42 |
43 | startView.frame = [self.startView convertRect:self.startView.bounds toView: containerView];
44 | toVC.view.alpha = 0;
45 | self.startView.hidden = YES;
46 | self.targetView.hidden = YES;
47 | fromVC.view.alpha = 1;
48 |
49 | __weak typeof(self) weakSelf = self;
50 |
51 |
52 | void(^AnimationBlock)() = ^(){
53 | startView.frame = [weakSelf.targetView convertRect:weakSelf.targetView.bounds toView:containerView];
54 | toVC.view.alpha = 1;
55 | fromVC.view.alpha = 0.0;
56 | };
57 |
58 | void(^AnimationCompletion)() = ^(void){
59 | startView.hidden = YES;
60 | weakSelf.startView.hidden = NO;
61 | weakSelf.targetView.hidden = NO;
62 | fromVC.view.alpha = 1;
63 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
64 | };
65 |
66 |
67 | if (type == WXSTransitionAnimationTypeViewMoveToNextVC) {
68 |
69 | [UIView animateWithDuration:self.animationTime delay:0.0 usingSpringWithDamping:0.7 initialSpringVelocity:1 / 0.7 options:0 animations:^{
70 | AnimationBlock();
71 | } completion:^(BOOL finished) {
72 | AnimationCompletion();
73 | }];
74 |
75 | }else {
76 |
77 | [UIView animateWithDuration:self.animationTime animations:^{
78 | AnimationBlock();
79 | } completion:^(BOOL finished) {
80 | AnimationCompletion();
81 | }];
82 |
83 | }
84 |
85 | }
86 |
87 | - (void)viewMoveBackWithType:(WXSTransitionAnimationType )type andContext:(id)transitionContext{
88 |
89 |
90 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
91 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
92 | UIView *containerView = [transitionContext containerView];
93 | UIView *tempView = containerView.subviews.lastObject;
94 | [containerView insertSubview:toVC.view atIndex:0];
95 | //Default values
96 | self.targetView.hidden = YES;
97 | self.startView.hidden = YES;
98 | tempView.hidden = NO;
99 | toVC.view.hidden = NO;
100 | toVC.view.alpha = 1;
101 | fromVC.view.alpha = 1;
102 | tempView.frame = [self.targetView convertRect:self.targetView.bounds toView:fromVC.view];
103 | __weak typeof(self) weakSelf = self;
104 | void(^AnimationBlock)() = ^(){
105 | tempView.frame = [weakSelf.startView convertRect:weakSelf.startView.bounds toView:containerView];
106 | fromVC.view.alpha = 0;
107 | toVC.view.alpha = 1;
108 | };
109 |
110 | void(^AnimationCompletion)() = ^(void){
111 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
112 | if ([transitionContext transitionWasCancelled]) {
113 | tempView.hidden = YES;
114 | weakSelf.targetView.hidden = NO;
115 | weakSelf.startView.hidden = NO;
116 | }else{
117 | weakSelf.startView.hidden = NO;
118 | weakSelf.targetView.hidden = YES;
119 | toVC.view.hidden = NO;
120 | [tempView removeFromSuperview];
121 | }
122 | fromVC.view.hidden = NO;
123 | };
124 |
125 |
126 | if (type == WXSTransitionAnimationTypeViewMoveToNextVC) {
127 |
128 | [UIView animateWithDuration:self.animationTime delay:0.0 usingSpringWithDamping:0.7 initialSpringVelocity:1 / 0.7 options:0 animations:^{
129 | AnimationBlock();
130 | } completion:^(BOOL finished) {
131 | AnimationCompletion();
132 | }];
133 |
134 | }else {
135 |
136 | [UIView animateWithDuration:self.animationTime animations:^{
137 | AnimationBlock();
138 | } completion:^(BOOL finished) {
139 |
140 | AnimationCompletion();
141 | }];
142 |
143 | }
144 | __weak UIViewController * weakFromVC = fromVC;
145 | self.willEndInteractiveBlock = ^(BOOL success){
146 |
147 | if (success) {
148 |
149 | weakFromVC.view.hidden = YES;
150 | weakSelf.startView.hidden = NO;
151 | weakSelf.targetView.hidden = YES;
152 | [tempView removeFromSuperview];
153 |
154 | }else{
155 | tempView.hidden = YES;
156 | weakSelf.startView.hidden = NO;
157 | weakSelf.targetView.hidden = NO;
158 |
159 | }
160 | };
161 |
162 | }
163 |
164 |
165 | @end
166 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #import
4 | #import "WXSTypedefConfig.h"
5 | @interface WXSTransitionManager : NSObject
6 |
7 |
8 | @property (nonatomic, assign) NSTimeInterval animationTime;
9 | @property (nonatomic, assign) WXSTransitionType transitionType;
10 | @property (nonatomic, assign) WXSTransitionAnimationType animationType;
11 | @property (nonatomic, assign) WXSTransitionAnimationType backAnimationType;
12 | @property (nonatomic, assign) WXSGestureType backGestureType;
13 |
14 | @property (nonatomic, weak) UIView *startView;
15 | @property (nonatomic, weak) UIView *targetView;
16 |
17 | @property (nonatomic, assign) BOOL isSysBackAnimation;
18 | @property (nonatomic, assign) BOOL autoShowAndHideNavBar;
19 | @property (nonatomic, assign) BOOL backGestureEnable;
20 |
21 | @property (nonatomic, copy) void(^willEndInteractiveBlock)(BOOL success);
22 | @property (nonatomic, copy) void(^completionBlock)();
23 |
24 |
25 | +(WXSTransitionManager *)copyPropertyFromObjcet:(id)object toObjcet:(id)targetObjcet;
26 |
27 | - (UIImage *)imageFromView: (UIView *)view atFrame:(CGRect)rect;
28 |
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionManager.m:
--------------------------------------------------------------------------------
1 |
2 | #import "WXSTransitionManager.h"
3 | #import "UIViewController+WXSTransition.h"
4 | #import
5 | #import
6 | #import "WXSTransitionManager+FragmentAnimation.h"
7 | #import "WXSTransitionManager+TypeTool.h"
8 | #import "WXSTransitionManager+BrickAnimation.h"
9 | #import "WXSTransitionManager+SpreadAnimation.h"
10 | #import "WXSTransitionManager+ViewMoveAnimation.h"
11 | #import "WXSTransitionManager+CoverAnimation.h"
12 | #import "WXSTransitionManager+SystermAnimation.h"
13 | #import "WXSTransitionManager+PageAnimation.h"
14 | #import "WXSTransitionManager+BoomAnimation.h"
15 | #import "WXSTransitionManager+InsideThenPushAnimation.h"
16 | #import "WXSTransitionManager+FlipAnimation.h"
17 |
18 | @interface WXSTransitionManager ()
19 |
20 | @property (nonatomic, assign) id transitionContext;
21 |
22 | @end
23 |
24 | @implementation WXSTransitionManager
25 |
26 | -(instancetype)init {
27 | self = [super init];
28 | if (self) {
29 |
30 | _completionBlock = nil;
31 |
32 | }
33 | return self;
34 | }
35 |
36 | #pragma mark - Delegate
37 | //UIViewControllerAnimatedTransitioning
38 | - (NSTimeInterval)transitionDuration:(id)transitionContext{
39 | return _animationTime ;
40 | }
41 |
42 | - (void)animationEnded:(BOOL) transitionCompleted {
43 |
44 | if (transitionCompleted) {
45 | [self removeDelegate];
46 | }
47 | UIViewController *toVC = [_transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
48 | if (toVC.navigationController.navigationBar && self.autoShowAndHideNavBar) {
49 | [UIView animateWithDuration:0.2 animations:^{
50 | toVC.navigationController.navigationBar.alpha = 1.0;
51 | }];
52 | }
53 |
54 | }
55 | - (void)animateTransition:(id )transitionContext{
56 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
57 | if (fromVC.navigationController.navigationBar && self.autoShowAndHideNavBar) {
58 | fromVC.navigationController.navigationBar.alpha = 0.0;
59 | }
60 |
61 | _transitionContext = transitionContext;
62 | if (self.animationType == WXSTransitionAnimationTypeDefault) {
63 | self.animationType = WXSTransitionAnimationTypeSysPushFromLeft;
64 | }
65 | switch (_transitionType) {
66 | case WXSTransitionTypePush:
67 | case WXSTransitionTypePresent:
68 | [self transitionActionAnimation:transitionContext withAnimationType:self.animationType];
69 | break;
70 | case WXSTransitionTypePop:
71 | case WXSTransitionTypeDismiss:
72 | [self transitionBackAnimation:transitionContext withAnimationType:self.animationType];
73 | break;
74 | default:
75 | break;
76 | }
77 |
78 | }
79 |
80 | -(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
81 |
82 | if (flag) {
83 | _completionBlock ? _completionBlock() : nil;
84 | _completionBlock = nil;
85 | }
86 |
87 | }
88 | #pragma mark - Action
89 | -(void)transitionActionAnimation:(id)transitionContext withAnimationType:(WXSTransitionAnimationType )animationType{
90 |
91 | if ((NSInteger)animationType < (NSInteger)WXSTransitionAnimationTypeDefault) {
92 | [self sysTransitionAnimationWithType:animationType context:transitionContext];
93 | }
94 | unsigned int count = 0;
95 | Method *methodlist = class_copyMethodList([WXSTransitionManager class], &count);
96 | int tag= 0;
97 | for (int i = 0; i < count; i++) {
98 | Method method = methodlist[i];
99 | SEL selector = method_getName(method);
100 | NSString *methodName = NSStringFromSelector(selector);
101 | if ([methodName rangeOfString:@"NextTransitionAnimation"].location != NSNotFound) {
102 | tag++;
103 | if (tag == animationType - WXSTransitionAnimationTypeDefault) {
104 | ((void (*)(id,SEL,id,WXSTransitionAnimationType))objc_msgSend)(self,selector,transitionContext,animationType);
105 | break;
106 | }
107 | }
108 | }
109 | free(methodlist);
110 |
111 | }
112 |
113 | -(void)transitionBackAnimation:(id)transitionContext withAnimationType:(WXSTransitionAnimationType )animationType{
114 |
115 | if ((NSInteger)animationType < (NSInteger)WXSTransitionAnimationTypeDefault) {
116 | [self backSysTransitionAnimationWithType:_backAnimationType context:transitionContext];
117 | }
118 |
119 | unsigned int count = 0;
120 | Method *methodlist = class_copyMethodList([WXSTransitionManager class], &count);
121 | int tag= 0;
122 | for (int i = 0; i < count; i++) {
123 | Method method = methodlist[i];
124 | SEL selector = method_getName(method);
125 | NSString *methodName = NSStringFromSelector(selector);
126 | if ([methodName rangeOfString:@"BackTransitionAnimation"].location != NSNotFound) {
127 | tag++;
128 | if (tag == animationType - WXSTransitionAnimationTypeDefault) {
129 | ((void (*)(id,SEL,id,WXSTransitionAnimationType))objc_msgSend)(self,selector,transitionContext,animationType);
130 | break;
131 | }
132 |
133 | }
134 | }
135 | free(methodlist);
136 |
137 | }
138 |
139 | -(void)sysTransitionAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext{
140 | [self sysTransitionNextAnimationWithType:type context:transitionContext];
141 | }
142 |
143 | -(void)backSysTransitionAnimationWithType:(WXSTransitionAnimationType) type context:(id)transitionContext{
144 | [self sysTransitionBackAnimationWithType:type context:transitionContext];
145 | }
146 | #pragma mark - Animations
147 |
148 | // *********************************************************************************************
149 | -(void)pageNextTransitionAnimation:(id)transitionContext {
150 | [self pageTransitionNextAnimationWithContext:transitionContext];
151 | }
152 | -(void)pageBackTransitionAnimation:(id)transitionContext {
153 | [self pageTransitionBackAnimationWithContext:transitionContext];
154 | }
155 |
156 |
157 | // *********************************************************************************************
158 | -(void)viewMoveNextTransitionAnimation:(id)transitionContext{
159 | [self viewMoveNextWithType:WXSTransitionAnimationTypeViewMoveToNextVC andContext:transitionContext];
160 | }
161 | -(void)viewMoveBackTransitionAnimation:(id)transitionContext{
162 | [self viewMoveBackWithType:WXSTransitionAnimationTypeViewMoveToNextVC andContext:transitionContext];
163 | }
164 | -(void)viewMoveNormalNextTransitionAnimation:(id)transitionContext{
165 | [self viewMoveNextWithType:WXSTransitionAnimationTypeViewMoveNormalToNextVC andContext:transitionContext];
166 | }
167 | -(void)viewMoveNormalBackTransitionAnimation:(id)transitionContext{
168 | [self viewMoveBackWithType:WXSTransitionAnimationTypeViewMoveNormalToNextVC andContext:transitionContext];
169 | }
170 |
171 |
172 | // *********************************************************************************************
173 | -(void)coverNextTransitionAnimation:(id)transitionContext{
174 | [self coverTransitionNextAnimationWithContext:transitionContext];
175 | }
176 | -(void)coverBackTransitionAnimation:(id)transitionContext{
177 | [self coverTransitionBackAnimationWithContext:transitionContext];
178 | }
179 |
180 |
181 |
182 | // *********************************************************************************************
183 | -(void)spreadFromRightNextTransitionAnimation:(id)transitionContext{
184 | [self spreadNextWithType:WXSTransitionAnimationTypeSpreadFromRight andTransitonContext:transitionContext];
185 | }
186 | -(void)spreadFromRightBackTransitionAnimation:(id)transitionContext{
187 | [self spreadBackWithType:WXSTransitionAnimationTypeSpreadFromRight andTransitonContext:transitionContext];
188 | }
189 | -(void)spreadFromLeftNextTransitionAnimation:(id)transitionContext{
190 | [self spreadNextWithType:WXSTransitionAnimationTypeSpreadFromLeft andTransitonContext:transitionContext];
191 | }
192 | -(void)spreadFromLeftBackTransitionAnimation:(id)transitionContext{
193 | [self spreadBackWithType:WXSTransitionAnimationTypeSpreadFromLeft andTransitonContext:transitionContext];
194 | }
195 | -(void)spreadFromTopNextTransitionAnimation:(id)transitionContext{
196 | [self spreadNextWithType:WXSTransitionAnimationTypeSpreadFromTop andTransitonContext:transitionContext];
197 | }
198 | -(void)spreadFromTopBackTransitionAnimation:(id)transitionContext{
199 | [self spreadBackWithType:WXSTransitionAnimationTypeSpreadFromTop andTransitonContext:transitionContext];
200 | }
201 | -(void)spreadFromBottomNextTransitionAnimation:(id)transitionContext{
202 | [self spreadNextWithType:WXSTransitionAnimationTypeSpreadFromBottom andTransitonContext:transitionContext];
203 | }
204 | -(void)spreadFromBottomBackTransitionAnimation:(id)transitionContext{
205 | [self spreadBackWithType:WXSTransitionAnimationTypeSpreadFromBottom andTransitonContext:transitionContext];
206 | }
207 | -(void)pointSpreadPresentNextTransitionAnimation:(id)transitionContext{
208 | [self pointSpreadNextWithContext:transitionContext];
209 | }
210 | -(void)pointSpreadPresentBackTransitionAnimation:(id)transitionContext{
211 | [self pointSpreadBackWithContext:transitionContext];
212 | }
213 |
214 |
215 | // *********************************************************************************************
216 | -(void)boomPresentNextTransitionAnimation:(id)transitionContext{
217 | [self boomPresentTransitionNextAnimation:transitionContext];
218 | }
219 | -(void)boomPresentBackTransitionAnimation:(id)transitionContext{
220 | [self boomPresentTransitionBackAnimation:transitionContext];
221 | }
222 |
223 |
224 | // *********************************************************************************************
225 | -(void)brickOpenVerticalNextTransitionAnimation:(id)transitionContext{
226 | [self brickOpenNextWithType:WXSTransitionAnimationTypeBrickOpenVertical andTransitionContext:transitionContext];
227 | }
228 | -(void)brickOpenVerticalBackTransitionAnimation:(id)transitionContext{
229 | [self brickOpenBackWithType:WXSTransitionAnimationTypeBrickOpenVertical andTransitionContext:transitionContext];
230 | }
231 | -(void)brickOpenHorizontalNextTransitionAnimation:(id)transitionContext{
232 | [self brickOpenNextWithType:WXSTransitionAnimationTypeBrickOpenHorizontal andTransitionContext:transitionContext];
233 | }
234 | -(void)brickOpenHorizontalBackTransitionAnimation:(id)transitionContext{
235 | [self brickOpenBackWithType:WXSTransitionAnimationTypeBrickOpenHorizontal andTransitionContext:transitionContext];
236 | }
237 | -(void)brickCloseVerticalNextTransitionAnimation:(id)transitionContext{
238 | [self brickCloseNextWithType:WXSTransitionAnimationTypeBrickCloseVertical andTransitionContext:transitionContext];
239 | }
240 | -(void)brickCloseVerticalBackTransitionAnimation:(id)transitionContext{
241 | [self brickCloseBackWithType:WXSTransitionAnimationTypeBrickCloseVertical andTransitionContext:transitionContext];
242 | }
243 | -(void)brickCloseHorizontalNextTransitionAnimation:(id)transitionContext{
244 | [self brickCloseNextWithType:WXSTransitionAnimationTypeBrickCloseHorizontal andTransitionContext:transitionContext];
245 | }
246 | -(void)brickCloseHorizontalBackTransitionAnimation:(id)transitionContext{
247 | [self brickCloseBackWithType:WXSTransitionAnimationTypeBrickCloseHorizontal andTransitionContext:transitionContext];
248 | }
249 |
250 |
251 | // *********************************************************************************************
252 | -(void)insideThenPushNextTransitionAnimation:(id)transitionContext{
253 | [self insideThenPushNextAnimationWithContext:transitionContext];
254 | }
255 | -(void)insideThenPushBackTransitionAnimation:(id)transitionContext {
256 | [self insideThenPushBackAnimationWithContext:transitionContext];
257 | }
258 |
259 |
260 |
261 | // *********************************************************************************************
262 | -(void)fragmentShowFromRightNextTransitionAnimation:(id)transitionContext{
263 | [self fragmentShowNextType:WXSTransitionAnimationTypeFragmentShowFromRight andContext:transitionContext];
264 | }
265 | -(void)fragmentShowFromRightBackTransitionAnimation:(id)transitionContext{
266 | [self fragmentShowBackType:WXSTransitionAnimationTypeFragmentShowFromRight andContext:transitionContext];
267 | }
268 | -(void)fragmentShowFromLeftNextTransitionAnimation:(id)transitionContext{
269 | [self fragmentShowNextType:WXSTransitionAnimationTypeFragmentShowFromLeft andContext:transitionContext];
270 | }
271 | -(void)fragmentShowFromLeftBackTransitionAnimation:(id)transitionContext{
272 | [self fragmentShowBackType:WXSTransitionAnimationTypeFragmentShowFromLeft andContext:transitionContext];
273 | }
274 | -(void)fragmentShowFromTopNextTransitionAnimation:(id)transitionContext{
275 | [self fragmentShowNextType:WXSTransitionAnimationTypeFragmentShowFromTop andContext:transitionContext];
276 | }
277 | -(void)fragmentShowFromTopBackTransitionAnimation:(id)transitionContext{
278 | [self fragmentShowBackType:WXSTransitionAnimationTypeFragmentShowFromTop andContext:transitionContext];
279 | }
280 | -(void)fragmentShowFromBottomNextTransitionAnimation:(id)transitionContext{
281 | [self fragmentShowNextType:WXSTransitionAnimationTypeFragmentShowFromBottom andContext:transitionContext];
282 | }
283 | -(void)fragmentShowFromBottomBackTransitionAnimation:(id)transitionContext{
284 | [self fragmentShowBackType:WXSTransitionAnimationTypeFragmentShowFromBottom andContext:transitionContext];
285 | }
286 | -(void)fragmentHideFromRightNextTransitionAnimation:(id)transitionContext{
287 | [self fragmentHideNextType:WXSTransitionAnimationTypeFragmentHideFromRight andContext:transitionContext];
288 | }
289 | -(void)fragmentHideFromRightBackTransitionAnimation:(id)transitionContext{
290 | [self fragmentHideBackType:WXSTransitionAnimationTypeFragmentHideFromRight andContext:transitionContext];
291 | }
292 | -(void)fragmentHideFromLefttNextTransitionAnimation:(id)transitionContext{
293 | [self fragmentHideNextType:WXSTransitionAnimationTypeFragmentHideFromLeft andContext:transitionContext];
294 | }
295 | -(void)fragmentHideFromLeftBackTransitionAnimation:(id)transitionContext{
296 | [self fragmentHideBackType:WXSTransitionAnimationTypeFragmentHideFromLeft andContext:transitionContext];
297 | }
298 | -(void)fragmentHideFromTopNextTransitionAnimation:(id)transitionContext{
299 | [self fragmentHideNextType:WXSTransitionAnimationTypeFragmentHideFromTop andContext:transitionContext];
300 | }
301 | -(void)fragmentHideFromTopBackTransitionAnimation:(id)transitionContext{
302 | [self fragmentHideBackType:WXSTransitionAnimationTypeFragmentHideFromTop andContext:transitionContext];
303 | }
304 | -(void)fragmentHideFromBottomNextTransitionAnimation:(id)transitionContext{
305 | [self fragmentHideNextType:WXSTransitionAnimationTypeFragmentHideFromBottom andContext:transitionContext];
306 | }
307 | -(void)fragmentHideFromBottomBackTransitionAnimation:(id)transitionContext{
308 | [self fragmentHideBackType:WXSTransitionAnimationTypeFragmentHideFromBottom andContext:transitionContext];
309 | }
310 | -(void)tipFlipNextTransitionAnimation:(id)transitionContext{
311 | [self tipFlipToNextAnimationContext:transitionContext];
312 | }
313 |
314 | -(void)tipFlipBackTransitionAnimation:(id)transitionContext{
315 | [self tipFlipBackAnimationContext:transitionContext];
316 | }
317 |
318 | // *********************************************************************************************
319 |
320 | #pragma mark - Other
321 | - (void)removeDelegate {
322 |
323 | UIViewController *fromVC = [_transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
324 | UIViewController *toVC = [_transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
325 |
326 | void (^RemoveDelegateBlock)() = ^(){
327 |
328 | fromVC.transitioningDelegate = nil;
329 | fromVC.navigationController.delegate = nil;
330 | toVC.transitioningDelegate = nil;
331 | toVC.navigationController.delegate = nil;
332 |
333 | };
334 |
335 | switch (self.transitionType) {
336 | case WXSTransitionTypePush:
337 | case WXSTransitionTypePresent:{ //Next
338 | if (self.isSysBackAnimation) {
339 | RemoveDelegateBlock ? RemoveDelegateBlock() : nil;
340 | }
341 | }
342 | break;
343 | default:{ //Back
344 | RemoveDelegateBlock ? RemoveDelegateBlock() : nil;
345 | }
346 | break;
347 | }
348 |
349 | }
350 |
351 |
352 | -(void)setAnimationType:(WXSTransitionAnimationType)animationType {
353 | _animationType = animationType;
354 | [self backAnimationTypeFromAnimationType:animationType];
355 | }
356 |
357 | +(WXSTransitionManager *)copyPropertyFromObjcet:(id)object toObjcet:(id)targetObjcet {
358 |
359 | WXSTransitionProperty *propery = object;
360 | WXSTransitionManager *transition = targetObjcet;
361 |
362 | transition.animationTime = propery.animationTime;
363 | transition.transitionType = propery.transitionType;
364 | transition.animationType = propery.animationType;
365 | transition.isSysBackAnimation = propery.isSysBackAnimation;
366 | transition.backGestureType = propery.backGestureType;
367 | transition.backGestureEnable = propery.backGestureEnable;
368 | transition.startView = propery.startView;
369 | transition.targetView = propery.targetView;
370 | transition.autoShowAndHideNavBar = propery.autoShowAndHideNavBar;
371 |
372 | return transition;
373 |
374 | }
375 | - (UIImage *)imageFromView: (UIView *)view atFrame:(CGRect)rect{
376 |
377 | UIGraphicsBeginImageContext(view.frame.size);
378 | CGContextRef context = UIGraphicsGetCurrentContext();
379 | CGContextSaveGState(context);
380 | UIRectClip(rect);
381 | [view.layer renderInContext:context];
382 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
383 | UIGraphicsEndImageContext();
384 | return theImage;
385 |
386 | }
387 |
388 | @end
389 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionProperty.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/7/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "WXSTypedefConfig.h"
12 |
13 | @interface WXSTransitionProperty : NSObject
14 |
15 | /**
16 | * 转场动画时间
17 | *
18 | * transitiion animation time
19 | */
20 | @property (nonatomic, assign) NSTimeInterval animationTime;
21 |
22 | /**
23 | * 转场方式 :push,pop,present,dismiss
24 | *
25 | * transitiion type :push,pop,present,dismiss
26 | */
27 | @property (nonatomic, assign) WXSTransitionType transitionType;
28 |
29 | /**
30 | * 转场动画类型
31 | *
32 | * transitiion animation type
33 | */
34 | @property (nonatomic, assign) WXSTransitionAnimationType animationType;
35 |
36 | /**
37 | * 是否采用系统原生返回方式
38 | * set YES to make back action of systerm
39 | */
40 | @property (nonatomic, assign) BOOL isSysBackAnimation;
41 |
42 | /**
43 | * 是否通过手势返回
44 | * set YES to enable gesture for back
45 | */
46 | @property (nonatomic, assign) BOOL backGestureEnable;
47 |
48 |
49 | /**
50 | * 在动画之前隐藏NavigationBar,动画结束后显示,默认为YES
51 | * hide NavigationBar befroe animation , then show NavigationBar after animation
52 | */
53 | @property (nonatomic, assign) BOOL autoShowAndHideNavBar;
54 |
55 | /**
56 | * 返回上个界面的手势 默认:右滑 :WXSGestureTypePanRight
57 | * choose type of gesture for back , default : WXSGestureTypePanRight
58 | */
59 | @property (nonatomic,assign) WXSGestureType backGestureType;
60 |
61 | /**
62 | * View move 等动画中指定的起始视图
63 | *
64 | */
65 | @property (nonatomic, strong) UIView *startView;
66 | /**
67 | * View move 等动画中指定的结束视图
68 | *
69 | */
70 | @property (nonatomic, strong) UIView *targetView;
71 |
72 |
73 |
74 |
75 |
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTransitionProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionProperty.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/7/1.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import "WXSTransitionProperty.h"
10 | #import
11 | #import
12 | @implementation WXSTransitionProperty
13 |
14 | -(instancetype)init {
15 | self = [super init];
16 | if (self) {
17 | _animationTime = 0.400082;
18 | self.animationType = WXSTransitionAnimationTypeDefault;
19 | _backGestureType = WXSGestureTypePanRight;
20 | _backGestureEnable = YES;
21 | _autoShowAndHideNavBar = YES;
22 | }
23 | return self;
24 | }
25 |
26 |
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/WXSTransition/WXSTransition/WXSTypedefConfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTypedefConfig.h
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/6/3.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #ifndef WXSTypedefConfig_h
10 | #define WXSTypedefConfig_h
11 |
12 |
13 | // ************** Enum **************
14 | typedef NS_ENUM(NSInteger,WXSTransitionAnimationType){
15 | //----------- 系统 ------------
16 | WXSTransitionAnimationTypeSysFade = 1, //淡入淡出
17 |
18 | WXSTransitionAnimationTypeSysPushFromRight,
19 | WXSTransitionAnimationTypeSysPushFromLeft,
20 | WXSTransitionAnimationTypeSysPushFromTop,
21 | WXSTransitionAnimationTypeSysPushFromBottom,//Push
22 |
23 | WXSTransitionAnimationTypeSysRevealFromRight,
24 | WXSTransitionAnimationTypeSysRevealFromLeft,
25 | WXSTransitionAnimationTypeSysRevealFromTop,
26 | WXSTransitionAnimationTypeSysRevealFromBottom,//揭开
27 |
28 | WXSTransitionAnimationTypeSysMoveInFromRight,
29 | WXSTransitionAnimationTypeSysMoveInFromLeft,
30 | WXSTransitionAnimationTypeSysMoveInFromTop,
31 | WXSTransitionAnimationTypeSysMoveInFromBottom,//覆盖
32 |
33 | WXSTransitionAnimationTypeSysCubeFromRight,
34 | WXSTransitionAnimationTypeSysCubeFromLeft,
35 | WXSTransitionAnimationTypeSysCubeFromTop,
36 | WXSTransitionAnimationTypeSysCubeFromBottom,//立方体
37 |
38 | WXSTransitionAnimationTypeSysSuckEffect, //吮吸
39 |
40 | WXSTransitionAnimationTypeSysOglFlipFromRight,
41 | WXSTransitionAnimationTypeSysOglFlipFromLeft,
42 | WXSTransitionAnimationTypeSysOglFlipFromTop,
43 | WXSTransitionAnimationTypeSysOglFlipFromBottom, //翻转
44 |
45 | WXSTransitionAnimationTypeSysRippleEffect, //波纹
46 |
47 | WXSTransitionAnimationTypeSysPageCurlFromRight,
48 | WXSTransitionAnimationTypeSysPageCurlFromLeft,
49 | WXSTransitionAnimationTypeSysPageCurlFromTop,
50 | WXSTransitionAnimationTypeSysPageCurlFromBottom,//翻页
51 |
52 | WXSTransitionAnimationTypeSysPageUnCurlFromRight,
53 | WXSTransitionAnimationTypeSysPageUnCurlFromLeft,
54 | WXSTransitionAnimationTypeSysPageUnCurlFromTop,
55 | WXSTransitionAnimationTypeSysPageUnCurlFromBottom,//反翻页
56 |
57 | WXSTransitionAnimationTypeSysCameraIrisHollowOpen, //开镜头
58 |
59 | WXSTransitionAnimationTypeSysCameraIrisHollowClose, //关镜头
60 |
61 | //----------- 自定义 ------------
62 | WXSTransitionAnimationTypeDefault,
63 |
64 | WXSTransitionAnimationTypePageTransition,
65 |
66 | WXSTransitionAnimationTypeViewMoveToNextVC,
67 | WXSTransitionAnimationTypeViewMoveNormalToNextVC,
68 |
69 | WXSTransitionAnimationTypeCover,
70 |
71 | WXSTransitionAnimationTypeSpreadFromRight,
72 | WXSTransitionAnimationTypeSpreadFromLeft,
73 | WXSTransitionAnimationTypeSpreadFromTop,
74 | WXSTransitionAnimationTypeSpreadFromBottom,
75 | WXSTransitionAnimationTypePointSpreadPresent,
76 |
77 | WXSTransitionAnimationTypeBoom,
78 |
79 | WXSTransitionAnimationTypeBrickOpenVertical,
80 | WXSTransitionAnimationTypeBrickOpenHorizontal,
81 | WXSTransitionAnimationTypeBrickCloseVertical,
82 | WXSTransitionAnimationTypeBrickCloseHorizontal,
83 |
84 | WXSTransitionAnimationTypeInsideThenPush,
85 |
86 | WXSTransitionAnimationTypeFragmentShowFromRight,
87 | WXSTransitionAnimationTypeFragmentShowFromLeft,
88 | WXSTransitionAnimationTypeFragmentShowFromTop,
89 | WXSTransitionAnimationTypeFragmentShowFromBottom,
90 |
91 | WXSTransitionAnimationTypeFragmentHideFromRight,
92 | WXSTransitionAnimationTypeFragmentHideFromLeft,
93 | WXSTransitionAnimationTypeFragmentHideFromTop,
94 | WXSTransitionAnimationTypeFragmentHideFromBottom,
95 | WXSTransitionAnimationTypeTipFlip,
96 |
97 | };
98 |
99 | typedef NS_ENUM(NSInteger,WXSTransitionType){
100 |
101 | WXSTransitionTypePop,
102 | WXSTransitionTypePush,
103 | WXSTransitionTypePresent,
104 | WXSTransitionTypeDismiss,
105 | };
106 |
107 |
108 | typedef NS_ENUM(NSInteger,WXSGestureType){
109 |
110 | WXSGestureTypeNone,
111 | WXSGestureTypePanLeft,
112 | WXSGestureTypePanRight,
113 | WXSGestureTypePanUp,
114 | WXSGestureTypePanDown,
115 |
116 | };
117 | //系统动画类型
118 | typedef NS_ENUM(NSInteger,WXSTransitionSysAnimationType){
119 |
120 | WXSTransitionSysAnimationTypeFade = 1, //淡入淡出
121 | WXSTransitionSysAnimationTypePush, //推挤
122 | WXSTransitionSysAnimationTypeReveal, //揭开
123 | WXSTransitionSysAnimationTypeMoveIn, //覆盖
124 | WXSTransitionSysAnimationTypeCube, //立方体
125 | WXSTransitionSysAnimationTypeSuckEffect, //吮吸
126 | WXSTransitionSysAnimationTypeOglFlip, //翻转
127 | WXSTransitionSysAnimationTypeRippleEffect, //波纹
128 | WXSTransitionSysAnimationTypePageCurl, //翻页
129 | WXSTransitionSysAnimationTypePageUnCurl, //反翻页
130 | WXSTransitionSysAnimationTypeCameraIrisHollowOpen, //开镜头
131 | WXSTransitionSysAnimationTypeCameraIrisHollowClose, //关镜头
132 | WXSTransitionSysAnimationTypeCurlDown, //下翻页
133 | WXSTransitionSysAnimationTypeCurlUp, //上翻页
134 | WXSTransitionSysAnimationTypeFlipFromLeft, //左翻转
135 | WXSTransitionSysAnimationTypeFlipFromRight, //右翻转
136 |
137 | };
138 |
139 |
140 |
141 | #endif /* WXSTypedefConfig_h */
142 |
--------------------------------------------------------------------------------
/WXSTransition/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // WXSTransition
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WXSTransitionTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/WXSTransitionTests/WXSTransitionTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionTests.m
3 | // WXSTransitionTests
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WXSTransitionTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation WXSTransitionTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/WXSTransitionUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/WXSTransitionUITests/WXSTransitionUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // WXSTransitionUITests.m
3 | // WXSTransitionUITests
4 | //
5 | // Created by 王小树 on 16/5/30.
6 | // Copyright © 2016年 王小树. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WXSTransitionUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation WXSTransitionUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/gif/boom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/boom.gif
--------------------------------------------------------------------------------
/gif/brick_close_H.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/brick_close_H.gif
--------------------------------------------------------------------------------
/gif/brick_open_V.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/brick_open_V.gif
--------------------------------------------------------------------------------
/gif/cover.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/cover.gif
--------------------------------------------------------------------------------
/gif/flip.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/flip.gif
--------------------------------------------------------------------------------
/gif/fragmentFromTop.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/fragmentFromTop.gif
--------------------------------------------------------------------------------
/gif/frgmentFromRight.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/frgmentFromRight.gif
--------------------------------------------------------------------------------
/gif/gestureSpread.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/gestureSpread.gif
--------------------------------------------------------------------------------
/gif/insideThenPush.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/insideThenPush.gif
--------------------------------------------------------------------------------
/gif/normalViewMove.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/normalViewMove.gif
--------------------------------------------------------------------------------
/gif/point_spread.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/point_spread.gif
--------------------------------------------------------------------------------
/gif/spread_from_right.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/spread_from_right.gif
--------------------------------------------------------------------------------
/gif/spread_from_top.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/spread_from_top.gif
--------------------------------------------------------------------------------
/gif/sys_oglFlip.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/sys_oglFlip.gif
--------------------------------------------------------------------------------
/gif/sys_pageCurl.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/sys_pageCurl.gif
--------------------------------------------------------------------------------
/gif/view_move_next.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanwangmodify/WXSTransition/818a677efc65333b1cb68291d380e0f6cfd02749/gif/view_move_next.gif
--------------------------------------------------------------------------------