├── Screenshot └── ss.gif ├── Demo ├── ZFModalTransitionDemo │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── ViewController.h │ ├── AppDelegate.h │ ├── ModalViewController.h │ ├── main.m │ ├── ZFModalTransitionDemo-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── ModalViewController.m │ ├── ZFModalTransitionDemo-Info.plist │ ├── ViewController.m │ ├── AppDelegate.m │ └── Base.lproj │ │ └── Main.storyboard ├── ZFModalTransitionDemoTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── ZFModalTransitionDemoTests-Info.plist │ └── ZFModalTransitionDemoTests.m └── ZFModalTransitionDemo.xcodeproj │ └── project.pbxproj ├── .gitignore ├── ZFDragableModalTransition ├── ZFDragableModalTransition.h ├── Info.plist ├── ZFModalTransitionAnimator.h └── ZFModalTransitionAnimator.m ├── CHANGELOG.md ├── ZFDragableModalTransition.podspec ├── LICENSE ├── README.md ├── ZFDragableModalTransition.xcodeproj ├── xcshareddata │ └── xcschemes │ │ └── ZFDragableModalTransition-iOS.xcscheme └── project.pbxproj └── Rakefile /Screenshot/ss.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoonooz/ZFDragableModalTransition/HEAD/Screenshot/ss.gif -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac 2 | .DS_Store 3 | 4 | # Xcode 5 | build/* 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | *.xcworkspace 15 | !default.xcworkspace 16 | xcuserdata 17 | profile 18 | *.moved-aside 19 | 20 | xcuserdata/ 21 | project.xcworkspace/ 22 | 23 | Carthage/ -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ModalViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModalViewController.h 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ModalViewController : UIViewController 12 | 13 | @property (nonatomic, weak) IBOutlet UIScrollView *scrollView; 14 | @property BOOL isShowingScrollView; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ZFModalTransitionDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ZFDragableModalTransition/ZFDragableModalTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZFDragableModalTransition.h 3 | // ZFDragableModalTransition 4 | // 5 | // Created by Denys Kotelovych on 12/20/15. 6 | // Copyright © 2015 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ZFDragableModalTransition. 12 | FOUNDATION_EXPORT double ZFDragableModalTransitionVersionNumber; 13 | 14 | //! Project version string for ZFDragableModalTransition. 15 | FOUNDATION_EXPORT const unsigned char ZFDragableModalTransitionVersionString[]; 16 | 17 | #ifdef __OBJC__ 18 | #import "ZFModalTransitionAnimator.h" 19 | #endif 20 | 21 | // In this header, you should import all the public headers of your framework using statements like #import 22 | 23 | 24 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemoTests/ZFModalTransitionDemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.zoonref.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemoTests/ZFModalTransitionDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZFModalTransitionDemoTests.m 3 | // ZFModalTransitionDemoTests 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZFModalTransitionDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ZFModalTransitionDemoTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ZFDragableModalTransition CHANGELOG 2 | 3 | ## 0.6 4 | 5 | - fix #50 In-call status bar animation make the dismissing end up in wrong scale 6 | - fix #51 7 | - fix wrongly handle `modalPresentationStyle` options 8 | 9 | ## 0.5.1 10 | 11 | - fix animator strongly reference to modal view controller 12 | 13 | ## 0.5.0 14 | 15 | - added neccessary appearance methods call for view controller 16 | 17 | ## 0.4.0 18 | 19 | - fix sometimes layout mess when rotate, wrong scale in iOS7 20 | - fix rotation issue 21 | - added transitionDuration property, adjust bounce 22 | 23 | ## 0.3.0 24 | 25 | - rename `scaleDownRatio` to `behindViewScale`, added `behindViewAlpha` 26 | - Fixed rotation issue 27 | - added bounces option 28 | 29 | ## 0.2.0 30 | 31 | - Added `scaleDownRatio` to let you set the size ratio of the view when it goes behind. 32 | - Fixed view disappear in ios8 beta 33 | 34 | ## 0.1.0 35 | 36 | Initial release. 37 | -------------------------------------------------------------------------------- /ZFDragableModalTransition/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 | FMWK 17 | CFBundleShortVersionString 18 | 0.5.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZFDragableModalTransition.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint NAME.podspec' to ensure this is a 3 | # valid spec and remove all comments before submitting the spec. 4 | # 5 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 6 | # 7 | Pod::Spec.new do |s| 8 | s.name = "ZFDragableModalTransition" 9 | s.version = "0.6" 10 | s.summary = "Custom animation transition for present modal view controller" 11 | s.homepage = "https://github.com/zoonooz/ZFDragableModalTransition" 12 | s.license = 'MIT' 13 | s.author = { "Amornchai Kanokpullwad" => "amornchai.zoon@gmail.com" } 14 | s.source = { :git => "https://github.com/zoonooz/ZFDragableModalTransition.git", :tag => s.version.to_s } 15 | s.platform = :ios, '7.1' 16 | s.requires_arc = true 17 | s.source_files = 'ZFDragableModalTransition' 18 | s.ios.deployment_target = '7.1' 19 | end 20 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ModalViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModalViewController.m 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import "ModalViewController.h" 10 | 11 | @interface ModalViewController () 12 | 13 | @end 14 | 15 | @implementation ModalViewController 16 | 17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 18 | { 19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 20 | if (self) { 21 | // Custom initialization 22 | } 23 | return self; 24 | } 25 | 26 | - (void)viewDidLoad 27 | { 28 | [super viewDidLoad]; 29 | self.scrollView.hidden = !self.isShowingScrollView; 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | - (IBAction)closeButtonPressed:(id)sender 39 | { 40 | [self dismissViewControllerAnimated:YES completion:nil]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Amornchai Kanokpullwad 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. -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ZFModalTransitionDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.zoonref.${PRODUCT_NAME:rfc1034identifier} 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.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ZFDragableModalTransition/ZFModalTransitionAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZFModalTransitionAnimator.h 3 | // 4 | // Created by Amornchai Kanokpullwad on 5/10/14. 5 | // Copyright (c) 2014 zoonref. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | typedef NS_ENUM(NSUInteger, ZFModalTransitonDirection) { 13 | ZFModalTransitonDirectionBottom, 14 | ZFModalTransitonDirectionLeft, 15 | ZFModalTransitonDirectionRight, 16 | }; 17 | 18 | @interface ZFDetectScrollViewEndGestureRecognizer : UIPanGestureRecognizer 19 | @property (nonatomic, weak) UIScrollView *scrollview; 20 | @end 21 | 22 | @interface ZFModalTransitionAnimator : UIPercentDrivenInteractiveTransition 23 | 24 | @property (nonatomic, assign, getter=isDragable) BOOL dragable; 25 | @property (nonatomic, readonly) ZFDetectScrollViewEndGestureRecognizer *gesture; 26 | @property (nonatomic, assign) UIGestureRecognizer *gestureRecognizerToFailPan; 27 | @property BOOL bounces; 28 | @property (nonatomic) ZFModalTransitonDirection direction; 29 | @property CGFloat behindViewScale; 30 | @property CGFloat behindViewAlpha; 31 | @property CGFloat transitionDuration; 32 | 33 | - (id)initWithModalViewController:(UIViewController *)modalViewController; 34 | - (void)setContentScrollView:(UIScrollView *)scrollView; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ModalViewController.h" 11 | #import "ZFModalTransitionAnimator.h" 12 | 13 | @interface ViewController () 14 | @property (weak, nonatomic) IBOutlet UISwitch *dragableSwitch; 15 | @property (weak, nonatomic) IBOutlet UISwitch *scrollViewSwitch; 16 | @property (nonatomic, strong) ZFModalTransitionAnimator *animator; 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad 22 | { 23 | [super viewDidLoad]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning 27 | { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | - (IBAction)buttonPressed:(UIButton *)sender 33 | { 34 | ModalViewController *modalVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ModalViewController"]; 35 | modalVC.isShowingScrollView = self.scrollViewSwitch.isOn; 36 | modalVC.modalPresentationStyle = UIModalPresentationFullScreen; 37 | 38 | self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:modalVC]; 39 | self.animator.dragable = self.dragableSwitch.isOn; 40 | self.animator.bounces = NO; 41 | self.animator.behindViewAlpha = 0.5f; 42 | self.animator.behindViewScale = 0.5f; 43 | self.animator.transitionDuration = 0.7f; 44 | 45 | if (self.scrollViewSwitch.isOn) { 46 | [self.animator setContentScrollView:modalVC.scrollView]; 47 | } 48 | 49 | NSString *title = [sender titleForState:UIControlStateNormal]; 50 | if ([title isEqualToString:@"Left"]) { 51 | self.animator.direction = ZFModalTransitonDirectionLeft; 52 | } else if ([title isEqualToString:@"Right"]) { 53 | self.animator.direction = ZFModalTransitonDirectionRight; 54 | } else { 55 | self.animator.direction = ZFModalTransitonDirectionBottom; 56 | } 57 | 58 | modalVC.transitioningDelegate = self.animator; 59 | [self presentViewController:modalVC animated:YES completion:nil]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ZFModalTransitionDemo 4 | // 5 | // Created by Amornchai Kanokpullwad on 6/4/14. 6 | // Copyright (c) 2014 zoonref. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // 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. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 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 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZFDragableModalTransition 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/ZFDragableModalTransition.svg?style=flat)](http://cocoadocs.org/docsets/ZFDragableModalTransition) 4 | [![License](https://img.shields.io/cocoapods/l/ZFDragableModalTransition.svg?style=flat)](http://cocoadocs.org/docsets/ZFDragableModalTransition) 5 | [![Platform](https://img.shields.io/cocoapods/p/ZFDragableModalTransition.svg?style=flat)](http://cocoadocs.org/docsets/ZFDragableModalTransition) 6 | 7 |

8 | 9 | ## Usage 10 | 11 | ```objc 12 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 13 | { 14 | TaskDetailViewController *detailViewController = segue.destinationViewController; 15 | detailViewController.task = sender; 16 | 17 | // create animator object with instance of modal view controller 18 | // we need to keep it in property with strong reference so it will not get release 19 | self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:detailViewController]; 20 | self.animator.dragable = YES; 21 | self.animator.direction = ZFModalTransitonDirectionBottom; 22 | [self.animator setContentScrollView:detailViewController.scrollview]; 23 | 24 | // set transition delegate of modal view controller to our object 25 | detailViewController.transitioningDelegate = self.animator; 26 | 27 | // if you modal cover all behind view controller, use UIModalPresentationFullScreen 28 | detailViewController.modalPresentationStyle = UIModalPresentationCustom; 29 | } 30 | ``` 31 | ###ScrollView 32 | If you have scrollview in the modal and you want to dismiss modal by drag it, you need to set scrollview to ZFModalTransitionAnimator instance. 33 | ```objc 34 | [self.animator setContentScrollView:detailViewController.scrollview]; 35 | ``` 36 | 37 | ###Direction 38 | You can set that which direction will our modal present. (default is ZFModalTransitonDirectionBottom) 39 | ```objc 40 | self.animator.direction = ZFModalTransitonDirectionBottom; 41 | ``` 42 | P.S. Now you can set content scrollview only with ZFModalTransitonDirectionBottom 43 | 44 | ## Requirements 45 | - iOS >= 7.1 46 | - ARC 47 | 48 | ## Installation 49 | 50 | ZFDragableModalTransition is available through [CocoaPods](http://cocoapods.org). To install 51 | it, simply add the following line to your Podfile: 52 | 53 | pod "ZFDragableModalTransition" 54 | 55 | ## FAQ 56 | 57 | ### How can I show modal only part of view ? 58 | The current ViewController's view still visible behind the modal, so you just set transparent color to background view. 59 | 60 | ## Author 61 | 62 | Amornchai Kanokpullwad, [@zoonref](https://twitter.com/zoonref) 63 | 64 | ## Swift Version 65 | 66 | by @dimohamdy [ZFDragableModalTransitionSwift](https://github.com/dimohamdy/ZFDragableModalTransitionSwift) 67 | 68 | ## License 69 | 70 | ZFDragableModalTransition is available under the MIT license. See the LICENSE file for more info. 71 | -------------------------------------------------------------------------------- /ZFDragableModalTransition.xcodeproj/xcshareddata/xcschemes/ZFDragableModalTransition-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | desc "Runs the specs [EMPTY]" 2 | task :spec do 3 | # Provide your own implementation 4 | end 5 | 6 | task :version do 7 | git_remotes = `git remote`.strip.split("\n") 8 | 9 | if git_remotes.count > 0 10 | puts "-- fetching version number from github" 11 | sh 'git fetch' 12 | 13 | remote_version = remote_spec_version 14 | end 15 | 16 | if remote_version.nil? 17 | puts "There is no current released version. You're about to release a new Pod." 18 | version = "0.0.1" 19 | else 20 | puts "The current released version of your pod is " + 21 | remote_spec_version.to_s() 22 | version = suggested_version_number 23 | end 24 | 25 | puts "Enter the version you want to release (" + version + ") " 26 | new_version_number = $stdin.gets.strip 27 | if new_version_number == "" 28 | new_version_number = version 29 | end 30 | 31 | replace_version_number(new_version_number) 32 | end 33 | 34 | desc "Release a new version of the Pod (append repo=name to push to a private spec repo)" 35 | task :release do 36 | # Allow override of spec repo name using `repo=private` after task name 37 | repo = ENV["repo"] || "master" 38 | 39 | puts "* Running version" 40 | sh "rake version" 41 | 42 | unless ENV['SKIP_CHECKS'] 43 | if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master' 44 | $stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release." 45 | exit 1 46 | end 47 | 48 | if `git tag`.strip.split("\n").include?(spec_version) 49 | $stderr.puts "[!] A tag for version `#{spec_version}' already exists. Change the version in the podspec" 50 | exit 1 51 | end 52 | 53 | puts "You are about to release `#{spec_version}`, is that correct? [y/n]" 54 | exit if $stdin.gets.strip.downcase != 'y' 55 | end 56 | 57 | puts "* Running specs" 58 | sh "rake spec" 59 | 60 | puts "* Linting the podspec" 61 | sh "pod lib lint" 62 | 63 | # Then release 64 | sh "git commit #{podspec_path} CHANGELOG.md -m 'Release #{spec_version}' --allow-empty" 65 | sh "git tag -a #{spec_version} -m 'Release #{spec_version}'" 66 | sh "git push origin master" 67 | sh "git push origin --tags" 68 | sh "pod push #{repo} #{podspec_path}" 69 | end 70 | 71 | # @return [Pod::Version] The version as reported by the Podspec. 72 | # 73 | def spec_version 74 | require 'cocoapods' 75 | spec = Pod::Specification.from_file(podspec_path) 76 | spec.version 77 | end 78 | 79 | # @return [Pod::Version] The version as reported by the Podspec from remote. 80 | # 81 | def remote_spec_version 82 | require 'cocoapods-core' 83 | 84 | if spec_file_exist_on_remote? 85 | remote_spec = eval(`git show origin/master:#{podspec_path}`) 86 | remote_spec.version 87 | else 88 | nil 89 | end 90 | end 91 | 92 | # @return [Bool] If the remote repository has a copy of the podpesc file or not. 93 | # 94 | def spec_file_exist_on_remote? 95 | test_condition = `if git rev-parse --verify --quiet origin/master:#{podspec_path} >/dev/null; 96 | then 97 | echo 'true' 98 | else 99 | echo 'false' 100 | fi` 101 | 102 | 'true' == test_condition.strip 103 | end 104 | 105 | # @return [String] The relative path of the Podspec. 106 | # 107 | def podspec_path 108 | podspecs = Dir.glob('*.podspec') 109 | if podspecs.count == 1 110 | podspecs.first 111 | else 112 | raise "Could not select a podspec" 113 | end 114 | end 115 | 116 | # @return [String] The suggested version number based on the local and remote 117 | # version numbers. 118 | # 119 | def suggested_version_number 120 | if spec_version != remote_spec_version 121 | spec_version.to_s() 122 | else 123 | next_version(spec_version).to_s() 124 | end 125 | end 126 | 127 | # @param [Pod::Version] version 128 | # the version for which you need the next version 129 | # 130 | # @note It is computed by bumping the last component of 131 | # the version string by 1. 132 | # 133 | # @return [Pod::Version] The version that comes next after 134 | # the version supplied. 135 | # 136 | def next_version(version) 137 | version_components = version.to_s().split("."); 138 | last = (version_components.last.to_i() + 1).to_s 139 | version_components[-1] = last 140 | Pod::Version.new(version_components.join(".")) 141 | end 142 | 143 | # @param [String] new_version_number 144 | # the new version number 145 | # 146 | # @note This methods replaces the version number in the podspec file 147 | # with a new version number. 148 | # 149 | # @return void 150 | # 151 | def replace_version_number(new_version_number) 152 | text = File.read(podspec_path) 153 | text.gsub!(/(s.version( )*= ")#{spec_version}(")/, 154 | "\\1#{new_version_number}\\3") 155 | File.open(podspec_path, "w") { |file| file.puts text } 156 | end 157 | -------------------------------------------------------------------------------- /ZFDragableModalTransition.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 455343A21C27441F0013DD4D /* ZFDragableModalTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 455343A11C27441F0013DD4D /* ZFDragableModalTransition.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 455343AB1C2744850013DD4D /* ZFModalTransitionAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 455343A91C2744850013DD4D /* ZFModalTransitionAnimator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12 | 455343AC1C2744850013DD4D /* ZFModalTransitionAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 455343AA1C2744850013DD4D /* ZFModalTransitionAnimator.m */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXFileReference section */ 16 | 4553439E1C27441F0013DD4D /* ZFDragableModalTransition.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZFDragableModalTransition.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 17 | 455343A11C27441F0013DD4D /* ZFDragableModalTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZFDragableModalTransition.h; sourceTree = ""; }; 18 | 455343A31C27441F0013DD4D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 19 | 455343A91C2744850013DD4D /* ZFModalTransitionAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZFModalTransitionAnimator.h; sourceTree = ""; }; 20 | 455343AA1C2744850013DD4D /* ZFModalTransitionAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZFModalTransitionAnimator.m; sourceTree = ""; }; 21 | /* End PBXFileReference section */ 22 | 23 | /* Begin PBXFrameworksBuildPhase section */ 24 | 4553439A1C27441F0013DD4D /* Frameworks */ = { 25 | isa = PBXFrameworksBuildPhase; 26 | buildActionMask = 2147483647; 27 | files = ( 28 | ); 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXFrameworksBuildPhase section */ 32 | 33 | /* Begin PBXGroup section */ 34 | 455343941C27441F0013DD4D = { 35 | isa = PBXGroup; 36 | children = ( 37 | 455343A01C27441F0013DD4D /* ZFDragableModalTransition */, 38 | 4553439F1C27441F0013DD4D /* Products */, 39 | ); 40 | sourceTree = ""; 41 | }; 42 | 4553439F1C27441F0013DD4D /* Products */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 4553439E1C27441F0013DD4D /* ZFDragableModalTransition.framework */, 46 | ); 47 | name = Products; 48 | sourceTree = ""; 49 | }; 50 | 455343A01C27441F0013DD4D /* ZFDragableModalTransition */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 455343A91C2744850013DD4D /* ZFModalTransitionAnimator.h */, 54 | 455343AA1C2744850013DD4D /* ZFModalTransitionAnimator.m */, 55 | 455343A11C27441F0013DD4D /* ZFDragableModalTransition.h */, 56 | 455343A31C27441F0013DD4D /* Info.plist */, 57 | ); 58 | path = ZFDragableModalTransition; 59 | sourceTree = ""; 60 | }; 61 | /* End PBXGroup section */ 62 | 63 | /* Begin PBXHeadersBuildPhase section */ 64 | 4553439B1C27441F0013DD4D /* Headers */ = { 65 | isa = PBXHeadersBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | 455343AB1C2744850013DD4D /* ZFModalTransitionAnimator.h in Headers */, 69 | 455343A21C27441F0013DD4D /* ZFDragableModalTransition.h in Headers */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | /* End PBXHeadersBuildPhase section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 4553439D1C27441F0013DD4D /* ZFDragableModalTransition-iOS */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 455343A61C27441F0013DD4D /* Build configuration list for PBXNativeTarget "ZFDragableModalTransition-iOS" */; 79 | buildPhases = ( 80 | 455343991C27441F0013DD4D /* Sources */, 81 | 4553439A1C27441F0013DD4D /* Frameworks */, 82 | 4553439B1C27441F0013DD4D /* Headers */, 83 | 4553439C1C27441F0013DD4D /* Resources */, 84 | ); 85 | buildRules = ( 86 | ); 87 | dependencies = ( 88 | ); 89 | name = "ZFDragableModalTransition-iOS"; 90 | productName = ZFDragableModalTransition; 91 | productReference = 4553439E1C27441F0013DD4D /* ZFDragableModalTransition.framework */; 92 | productType = "com.apple.product-type.framework"; 93 | }; 94 | /* End PBXNativeTarget section */ 95 | 96 | /* Begin PBXProject section */ 97 | 455343951C27441F0013DD4D /* Project object */ = { 98 | isa = PBXProject; 99 | attributes = { 100 | LastUpgradeCheck = 0720; 101 | ORGANIZATIONNAME = zoonref; 102 | TargetAttributes = { 103 | 4553439D1C27441F0013DD4D = { 104 | CreatedOnToolsVersion = 7.2; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 455343981C27441F0013DD4D /* Build configuration list for PBXProject "ZFDragableModalTransition" */; 109 | compatibilityVersion = "Xcode 3.2"; 110 | developmentRegion = English; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | ); 115 | mainGroup = 455343941C27441F0013DD4D; 116 | productRefGroup = 4553439F1C27441F0013DD4D /* Products */; 117 | projectDirPath = ""; 118 | projectRoot = ""; 119 | targets = ( 120 | 4553439D1C27441F0013DD4D /* ZFDragableModalTransition-iOS */, 121 | ); 122 | }; 123 | /* End PBXProject section */ 124 | 125 | /* Begin PBXResourcesBuildPhase section */ 126 | 4553439C1C27441F0013DD4D /* Resources */ = { 127 | isa = PBXResourcesBuildPhase; 128 | buildActionMask = 2147483647; 129 | files = ( 130 | ); 131 | runOnlyForDeploymentPostprocessing = 0; 132 | }; 133 | /* End PBXResourcesBuildPhase section */ 134 | 135 | /* Begin PBXSourcesBuildPhase section */ 136 | 455343991C27441F0013DD4D /* Sources */ = { 137 | isa = PBXSourcesBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | 455343AC1C2744850013DD4D /* ZFModalTransitionAnimator.m in Sources */, 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXSourcesBuildPhase section */ 145 | 146 | /* Begin XCBuildConfiguration section */ 147 | 455343A41C27441F0013DD4D /* Debug */ = { 148 | isa = XCBuildConfiguration; 149 | buildSettings = { 150 | ALWAYS_SEARCH_USER_PATHS = NO; 151 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 152 | CLANG_CXX_LIBRARY = "libc++"; 153 | CLANG_ENABLE_MODULES = YES; 154 | CLANG_ENABLE_OBJC_ARC = YES; 155 | CLANG_WARN_BOOL_CONVERSION = YES; 156 | CLANG_WARN_CONSTANT_CONVERSION = YES; 157 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 158 | CLANG_WARN_EMPTY_BODY = YES; 159 | CLANG_WARN_ENUM_CONVERSION = YES; 160 | CLANG_WARN_INT_CONVERSION = YES; 161 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 162 | CLANG_WARN_UNREACHABLE_CODE = YES; 163 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 164 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 165 | COPY_PHASE_STRIP = NO; 166 | CURRENT_PROJECT_VERSION = 1; 167 | DEBUG_INFORMATION_FORMAT = dwarf; 168 | ENABLE_STRICT_OBJC_MSGSEND = YES; 169 | ENABLE_TESTABILITY = YES; 170 | GCC_C_LANGUAGE_STANDARD = gnu99; 171 | GCC_DYNAMIC_NO_PIC = NO; 172 | GCC_NO_COMMON_BLOCKS = YES; 173 | GCC_OPTIMIZATION_LEVEL = 0; 174 | GCC_PREPROCESSOR_DEFINITIONS = ( 175 | "DEBUG=1", 176 | "$(inherited)", 177 | ); 178 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 179 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 180 | GCC_WARN_UNDECLARED_SELECTOR = YES; 181 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 182 | GCC_WARN_UNUSED_FUNCTION = YES; 183 | GCC_WARN_UNUSED_VARIABLE = YES; 184 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 185 | MTL_ENABLE_DEBUG_INFO = YES; 186 | ONLY_ACTIVE_ARCH = YES; 187 | SDKROOT = iphoneos; 188 | TARGETED_DEVICE_FAMILY = "1,2"; 189 | VERSIONING_SYSTEM = "apple-generic"; 190 | VERSION_INFO_PREFIX = ""; 191 | }; 192 | name = Debug; 193 | }; 194 | 455343A51C27441F0013DD4D /* Release */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_CONSTANT_CONVERSION = YES; 204 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_UNREACHABLE_CODE = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | CURRENT_PROJECT_VERSION = 1; 214 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 215 | ENABLE_NS_ASSERTIONS = NO; 216 | ENABLE_STRICT_OBJC_MSGSEND = YES; 217 | GCC_C_LANGUAGE_STANDARD = gnu99; 218 | GCC_NO_COMMON_BLOCKS = YES; 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 226 | MTL_ENABLE_DEBUG_INFO = NO; 227 | SDKROOT = iphoneos; 228 | TARGETED_DEVICE_FAMILY = "1,2"; 229 | VALIDATE_PRODUCT = YES; 230 | VERSIONING_SYSTEM = "apple-generic"; 231 | VERSION_INFO_PREFIX = ""; 232 | }; 233 | name = Release; 234 | }; 235 | 455343A71C27441F0013DD4D /* Debug */ = { 236 | isa = XCBuildConfiguration; 237 | buildSettings = { 238 | DEFINES_MODULE = YES; 239 | DYLIB_COMPATIBILITY_VERSION = 1; 240 | DYLIB_CURRENT_VERSION = 1; 241 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 242 | INFOPLIST_FILE = ZFDragableModalTransition/Info.plist; 243 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 244 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 245 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 246 | PRODUCT_BUNDLE_IDENTIFIER = com.zoonref.id.ZFDragableModalTransition; 247 | PRODUCT_NAME = "$(PROJECT_NAME)"; 248 | SKIP_INSTALL = YES; 249 | }; 250 | name = Debug; 251 | }; 252 | 455343A81C27441F0013DD4D /* Release */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | DEFINES_MODULE = YES; 256 | DYLIB_COMPATIBILITY_VERSION = 1; 257 | DYLIB_CURRENT_VERSION = 1; 258 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 259 | INFOPLIST_FILE = ZFDragableModalTransition/Info.plist; 260 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 261 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 262 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 263 | PRODUCT_BUNDLE_IDENTIFIER = com.zoonref.id.ZFDragableModalTransition; 264 | PRODUCT_NAME = "$(PROJECT_NAME)"; 265 | SKIP_INSTALL = YES; 266 | }; 267 | name = Release; 268 | }; 269 | /* End XCBuildConfiguration section */ 270 | 271 | /* Begin XCConfigurationList section */ 272 | 455343981C27441F0013DD4D /* Build configuration list for PBXProject "ZFDragableModalTransition" */ = { 273 | isa = XCConfigurationList; 274 | buildConfigurations = ( 275 | 455343A41C27441F0013DD4D /* Debug */, 276 | 455343A51C27441F0013DD4D /* Release */, 277 | ); 278 | defaultConfigurationIsVisible = 0; 279 | defaultConfigurationName = Release; 280 | }; 281 | 455343A61C27441F0013DD4D /* Build configuration list for PBXNativeTarget "ZFDragableModalTransition-iOS" */ = { 282 | isa = XCConfigurationList; 283 | buildConfigurations = ( 284 | 455343A71C27441F0013DD4D /* Debug */, 285 | 455343A81C27441F0013DD4D /* Release */, 286 | ); 287 | defaultConfigurationIsVisible = 0; 288 | defaultConfigurationName = Release; 289 | }; 290 | /* End XCConfigurationList section */ 291 | }; 292 | rootObject = 455343951C27441F0013DD4D /* Project object */; 293 | } 294 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo/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 | 33 | 46 | 59 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 134 | 135 | 136 | 137 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 138 | 139 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 140 | 141 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 142 | 143 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /Demo/ZFModalTransitionDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DC15A4F2193F710800D293CE /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DC15A4F1193F710800D293CE /* ModalViewController.m */; }; 11 | DC81DC6B1DA0E84E00B94A5B /* ZFModalTransitionAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = DC81DC6A1DA0E84E00B94A5B /* ZFModalTransitionAnimator.m */; }; 12 | DCAD9954193F6E7300F0F385 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9953193F6E7300F0F385 /* Foundation.framework */; }; 13 | DCAD9956193F6E7300F0F385 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9955193F6E7300F0F385 /* CoreGraphics.framework */; }; 14 | DCAD9958193F6E7300F0F385 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9957193F6E7300F0F385 /* UIKit.framework */; }; 15 | DCAD995E193F6E7300F0F385 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DCAD995C193F6E7300F0F385 /* InfoPlist.strings */; }; 16 | DCAD9960193F6E7300F0F385 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAD995F193F6E7300F0F385 /* main.m */; }; 17 | DCAD9964193F6E7300F0F385 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAD9963193F6E7300F0F385 /* AppDelegate.m */; }; 18 | DCAD9967193F6E7300F0F385 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DCAD9965193F6E7300F0F385 /* Main.storyboard */; }; 19 | DCAD996A193F6E7300F0F385 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAD9969193F6E7300F0F385 /* ViewController.m */; }; 20 | DCAD996C193F6E7300F0F385 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCAD996B193F6E7300F0F385 /* Images.xcassets */; }; 21 | DCAD9973193F6E7300F0F385 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9972193F6E7300F0F385 /* XCTest.framework */; }; 22 | DCAD9974193F6E7300F0F385 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9953193F6E7300F0F385 /* Foundation.framework */; }; 23 | DCAD9975193F6E7300F0F385 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAD9957193F6E7300F0F385 /* UIKit.framework */; }; 24 | DCAD997D193F6E7300F0F385 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DCAD997B193F6E7300F0F385 /* InfoPlist.strings */; }; 25 | DCAD997F193F6E7300F0F385 /* ZFModalTransitionDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAD997E193F6E7300F0F385 /* ZFModalTransitionDemoTests.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | DCAD9976193F6E7300F0F385 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = DCAD9948193F6E7200F0F385 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = DCAD994F193F6E7300F0F385; 34 | remoteInfo = ZFModalTransitionDemo; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | DC15A4F0193F710800D293CE /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = ""; }; 40 | DC15A4F1193F710800D293CE /* ModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModalViewController.m; sourceTree = ""; }; 41 | DC81DC691DA0E84E00B94A5B /* ZFModalTransitionAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ZFModalTransitionAnimator.h; path = ../../ZFDragableModalTransition/ZFModalTransitionAnimator.h; sourceTree = ""; }; 42 | DC81DC6A1DA0E84E00B94A5B /* ZFModalTransitionAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ZFModalTransitionAnimator.m; path = ../../ZFDragableModalTransition/ZFModalTransitionAnimator.m; sourceTree = ""; }; 43 | DCAD9950193F6E7300F0F385 /* ZFModalTransitionDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZFModalTransitionDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | DCAD9953193F6E7300F0F385 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 45 | DCAD9955193F6E7300F0F385 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 46 | DCAD9957193F6E7300F0F385 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 47 | DCAD995B193F6E7300F0F385 /* ZFModalTransitionDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ZFModalTransitionDemo-Info.plist"; sourceTree = ""; }; 48 | DCAD995D193F6E7300F0F385 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 49 | DCAD995F193F6E7300F0F385 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | DCAD9961193F6E7300F0F385 /* ZFModalTransitionDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ZFModalTransitionDemo-Prefix.pch"; sourceTree = ""; }; 51 | DCAD9962193F6E7300F0F385 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 52 | DCAD9963193F6E7300F0F385 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 53 | DCAD9966193F6E7300F0F385 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 54 | DCAD9968193F6E7300F0F385 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 55 | DCAD9969193F6E7300F0F385 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 56 | DCAD996B193F6E7300F0F385 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 57 | DCAD9971193F6E7300F0F385 /* ZFModalTransitionDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZFModalTransitionDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | DCAD9972193F6E7300F0F385 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 59 | DCAD997A193F6E7300F0F385 /* ZFModalTransitionDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ZFModalTransitionDemoTests-Info.plist"; sourceTree = ""; }; 60 | DCAD997C193F6E7300F0F385 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 61 | DCAD997E193F6E7300F0F385 /* ZFModalTransitionDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZFModalTransitionDemoTests.m; sourceTree = ""; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | DCAD994D193F6E7300F0F385 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | DCAD9956193F6E7300F0F385 /* CoreGraphics.framework in Frameworks */, 70 | DCAD9958193F6E7300F0F385 /* UIKit.framework in Frameworks */, 71 | DCAD9954193F6E7300F0F385 /* Foundation.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | DCAD996E193F6E7300F0F385 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | DCAD9973193F6E7300F0F385 /* XCTest.framework in Frameworks */, 80 | DCAD9975193F6E7300F0F385 /* UIKit.framework in Frameworks */, 81 | DCAD9974193F6E7300F0F385 /* Foundation.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | /* End PBXFrameworksBuildPhase section */ 86 | 87 | /* Begin PBXGroup section */ 88 | DC81DC681DA0E82F00B94A5B /* Classes */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | DC81DC691DA0E84E00B94A5B /* ZFModalTransitionAnimator.h */, 92 | DC81DC6A1DA0E84E00B94A5B /* ZFModalTransitionAnimator.m */, 93 | ); 94 | name = Classes; 95 | sourceTree = ""; 96 | }; 97 | DCAD9947193F6E7200F0F385 = { 98 | isa = PBXGroup; 99 | children = ( 100 | DCAD9959193F6E7300F0F385 /* ZFModalTransitionDemo */, 101 | DCAD9978193F6E7300F0F385 /* ZFModalTransitionDemoTests */, 102 | DCAD9952193F6E7300F0F385 /* Frameworks */, 103 | DCAD9951193F6E7300F0F385 /* Products */, 104 | ); 105 | sourceTree = ""; 106 | }; 107 | DCAD9951193F6E7300F0F385 /* Products */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | DCAD9950193F6E7300F0F385 /* ZFModalTransitionDemo.app */, 111 | DCAD9971193F6E7300F0F385 /* ZFModalTransitionDemoTests.xctest */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | DCAD9952193F6E7300F0F385 /* Frameworks */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | DCAD9953193F6E7300F0F385 /* Foundation.framework */, 120 | DCAD9955193F6E7300F0F385 /* CoreGraphics.framework */, 121 | DCAD9957193F6E7300F0F385 /* UIKit.framework */, 122 | DCAD9972193F6E7300F0F385 /* XCTest.framework */, 123 | ); 124 | name = Frameworks; 125 | sourceTree = ""; 126 | }; 127 | DCAD9959193F6E7300F0F385 /* ZFModalTransitionDemo */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | DC81DC681DA0E82F00B94A5B /* Classes */, 131 | DCAD9962193F6E7300F0F385 /* AppDelegate.h */, 132 | DCAD9963193F6E7300F0F385 /* AppDelegate.m */, 133 | DCAD9965193F6E7300F0F385 /* Main.storyboard */, 134 | DCAD9968193F6E7300F0F385 /* ViewController.h */, 135 | DCAD9969193F6E7300F0F385 /* ViewController.m */, 136 | DC15A4F0193F710800D293CE /* ModalViewController.h */, 137 | DC15A4F1193F710800D293CE /* ModalViewController.m */, 138 | DCAD996B193F6E7300F0F385 /* Images.xcassets */, 139 | DCAD995A193F6E7300F0F385 /* Supporting Files */, 140 | ); 141 | path = ZFModalTransitionDemo; 142 | sourceTree = ""; 143 | }; 144 | DCAD995A193F6E7300F0F385 /* Supporting Files */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | DCAD995B193F6E7300F0F385 /* ZFModalTransitionDemo-Info.plist */, 148 | DCAD995C193F6E7300F0F385 /* InfoPlist.strings */, 149 | DCAD995F193F6E7300F0F385 /* main.m */, 150 | DCAD9961193F6E7300F0F385 /* ZFModalTransitionDemo-Prefix.pch */, 151 | ); 152 | name = "Supporting Files"; 153 | sourceTree = ""; 154 | }; 155 | DCAD9978193F6E7300F0F385 /* ZFModalTransitionDemoTests */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | DCAD997E193F6E7300F0F385 /* ZFModalTransitionDemoTests.m */, 159 | DCAD9979193F6E7300F0F385 /* Supporting Files */, 160 | ); 161 | path = ZFModalTransitionDemoTests; 162 | sourceTree = ""; 163 | }; 164 | DCAD9979193F6E7300F0F385 /* Supporting Files */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | DCAD997A193F6E7300F0F385 /* ZFModalTransitionDemoTests-Info.plist */, 168 | DCAD997B193F6E7300F0F385 /* InfoPlist.strings */, 169 | ); 170 | name = "Supporting Files"; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXGroup section */ 174 | 175 | /* Begin PBXNativeTarget section */ 176 | DCAD994F193F6E7300F0F385 /* ZFModalTransitionDemo */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = DCAD9982193F6E7300F0F385 /* Build configuration list for PBXNativeTarget "ZFModalTransitionDemo" */; 179 | buildPhases = ( 180 | DCAD994C193F6E7300F0F385 /* Sources */, 181 | DCAD994D193F6E7300F0F385 /* Frameworks */, 182 | DCAD994E193F6E7300F0F385 /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | ); 188 | name = ZFModalTransitionDemo; 189 | productName = ZFModalTransitionDemo; 190 | productReference = DCAD9950193F6E7300F0F385 /* ZFModalTransitionDemo.app */; 191 | productType = "com.apple.product-type.application"; 192 | }; 193 | DCAD9970193F6E7300F0F385 /* ZFModalTransitionDemoTests */ = { 194 | isa = PBXNativeTarget; 195 | buildConfigurationList = DCAD9985193F6E7300F0F385 /* Build configuration list for PBXNativeTarget "ZFModalTransitionDemoTests" */; 196 | buildPhases = ( 197 | DCAD996D193F6E7300F0F385 /* Sources */, 198 | DCAD996E193F6E7300F0F385 /* Frameworks */, 199 | DCAD996F193F6E7300F0F385 /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | DCAD9977193F6E7300F0F385 /* PBXTargetDependency */, 205 | ); 206 | name = ZFModalTransitionDemoTests; 207 | productName = ZFModalTransitionDemoTests; 208 | productReference = DCAD9971193F6E7300F0F385 /* ZFModalTransitionDemoTests.xctest */; 209 | productType = "com.apple.product-type.bundle.unit-test"; 210 | }; 211 | /* End PBXNativeTarget section */ 212 | 213 | /* Begin PBXProject section */ 214 | DCAD9948193F6E7200F0F385 /* Project object */ = { 215 | isa = PBXProject; 216 | attributes = { 217 | LastUpgradeCheck = 0510; 218 | ORGANIZATIONNAME = zoonref; 219 | TargetAttributes = { 220 | DCAD9970193F6E7300F0F385 = { 221 | TestTargetID = DCAD994F193F6E7300F0F385; 222 | }; 223 | }; 224 | }; 225 | buildConfigurationList = DCAD994B193F6E7200F0F385 /* Build configuration list for PBXProject "ZFModalTransitionDemo" */; 226 | compatibilityVersion = "Xcode 3.2"; 227 | developmentRegion = English; 228 | hasScannedForEncodings = 0; 229 | knownRegions = ( 230 | en, 231 | Base, 232 | ); 233 | mainGroup = DCAD9947193F6E7200F0F385; 234 | productRefGroup = DCAD9951193F6E7300F0F385 /* Products */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | DCAD994F193F6E7300F0F385 /* ZFModalTransitionDemo */, 239 | DCAD9970193F6E7300F0F385 /* ZFModalTransitionDemoTests */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | DCAD994E193F6E7300F0F385 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | DCAD996C193F6E7300F0F385 /* Images.xcassets in Resources */, 250 | DCAD995E193F6E7300F0F385 /* InfoPlist.strings in Resources */, 251 | DCAD9967193F6E7300F0F385 /* Main.storyboard in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | DCAD996F193F6E7300F0F385 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | DCAD997D193F6E7300F0F385 /* InfoPlist.strings in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXSourcesBuildPhase section */ 266 | DCAD994C193F6E7300F0F385 /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | DCAD996A193F6E7300F0F385 /* ViewController.m in Sources */, 271 | DC15A4F2193F710800D293CE /* ModalViewController.m in Sources */, 272 | DCAD9964193F6E7300F0F385 /* AppDelegate.m in Sources */, 273 | DCAD9960193F6E7300F0F385 /* main.m in Sources */, 274 | DC81DC6B1DA0E84E00B94A5B /* ZFModalTransitionAnimator.m in Sources */, 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | DCAD996D193F6E7300F0F385 /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | DCAD997F193F6E7300F0F385 /* ZFModalTransitionDemoTests.m in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXSourcesBuildPhase section */ 287 | 288 | /* Begin PBXTargetDependency section */ 289 | DCAD9977193F6E7300F0F385 /* PBXTargetDependency */ = { 290 | isa = PBXTargetDependency; 291 | target = DCAD994F193F6E7300F0F385 /* ZFModalTransitionDemo */; 292 | targetProxy = DCAD9976193F6E7300F0F385 /* PBXContainerItemProxy */; 293 | }; 294 | /* End PBXTargetDependency section */ 295 | 296 | /* Begin PBXVariantGroup section */ 297 | DCAD995C193F6E7300F0F385 /* InfoPlist.strings */ = { 298 | isa = PBXVariantGroup; 299 | children = ( 300 | DCAD995D193F6E7300F0F385 /* en */, 301 | ); 302 | name = InfoPlist.strings; 303 | sourceTree = ""; 304 | }; 305 | DCAD9965193F6E7300F0F385 /* Main.storyboard */ = { 306 | isa = PBXVariantGroup; 307 | children = ( 308 | DCAD9966193F6E7300F0F385 /* Base */, 309 | ); 310 | name = Main.storyboard; 311 | sourceTree = ""; 312 | }; 313 | DCAD997B193F6E7300F0F385 /* InfoPlist.strings */ = { 314 | isa = PBXVariantGroup; 315 | children = ( 316 | DCAD997C193F6E7300F0F385 /* en */, 317 | ); 318 | name = InfoPlist.strings; 319 | sourceTree = ""; 320 | }; 321 | /* End PBXVariantGroup section */ 322 | 323 | /* Begin XCBuildConfiguration section */ 324 | DCAD9980193F6E7300F0F385 /* Debug */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 341 | COPY_PHASE_STRIP = NO; 342 | GCC_C_LANGUAGE_STANDARD = gnu99; 343 | GCC_DYNAMIC_NO_PIC = NO; 344 | GCC_OPTIMIZATION_LEVEL = 0; 345 | GCC_PREPROCESSOR_DEFINITIONS = ( 346 | "DEBUG=1", 347 | "$(inherited)", 348 | ); 349 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 357 | ONLY_ACTIVE_ARCH = YES; 358 | SDKROOT = iphoneos; 359 | }; 360 | name = Debug; 361 | }; 362 | DCAD9981193F6E7300F0F385 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ALWAYS_SEARCH_USER_PATHS = NO; 366 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 367 | CLANG_CXX_LIBRARY = "libc++"; 368 | CLANG_ENABLE_MODULES = YES; 369 | CLANG_ENABLE_OBJC_ARC = YES; 370 | CLANG_WARN_BOOL_CONVERSION = YES; 371 | CLANG_WARN_CONSTANT_CONVERSION = YES; 372 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 373 | CLANG_WARN_EMPTY_BODY = YES; 374 | CLANG_WARN_ENUM_CONVERSION = YES; 375 | CLANG_WARN_INT_CONVERSION = YES; 376 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 377 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 378 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 379 | COPY_PHASE_STRIP = YES; 380 | ENABLE_NS_ASSERTIONS = NO; 381 | GCC_C_LANGUAGE_STANDARD = gnu99; 382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 383 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 384 | GCC_WARN_UNDECLARED_SELECTOR = YES; 385 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 386 | GCC_WARN_UNUSED_FUNCTION = YES; 387 | GCC_WARN_UNUSED_VARIABLE = YES; 388 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 389 | SDKROOT = iphoneos; 390 | VALIDATE_PRODUCT = YES; 391 | }; 392 | name = Release; 393 | }; 394 | DCAD9983193F6E7300F0F385 /* Debug */ = { 395 | isa = XCBuildConfiguration; 396 | buildSettings = { 397 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 398 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 399 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 400 | GCC_PREFIX_HEADER = "ZFModalTransitionDemo/ZFModalTransitionDemo-Prefix.pch"; 401 | INFOPLIST_FILE = "ZFModalTransitionDemo/ZFModalTransitionDemo-Info.plist"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | WRAPPER_EXTENSION = app; 404 | }; 405 | name = Debug; 406 | }; 407 | DCAD9984193F6E7300F0F385 /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 411 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 412 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 413 | GCC_PREFIX_HEADER = "ZFModalTransitionDemo/ZFModalTransitionDemo-Prefix.pch"; 414 | INFOPLIST_FILE = "ZFModalTransitionDemo/ZFModalTransitionDemo-Info.plist"; 415 | PRODUCT_NAME = "$(TARGET_NAME)"; 416 | WRAPPER_EXTENSION = app; 417 | }; 418 | name = Release; 419 | }; 420 | DCAD9986193F6E7300F0F385 /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ZFModalTransitionDemo.app/ZFModalTransitionDemo"; 424 | FRAMEWORK_SEARCH_PATHS = ( 425 | "$(SDKROOT)/Developer/Library/Frameworks", 426 | "$(inherited)", 427 | "$(DEVELOPER_FRAMEWORKS_DIR)", 428 | ); 429 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 430 | GCC_PREFIX_HEADER = "ZFModalTransitionDemo/ZFModalTransitionDemo-Prefix.pch"; 431 | GCC_PREPROCESSOR_DEFINITIONS = ( 432 | "DEBUG=1", 433 | "$(inherited)", 434 | ); 435 | INFOPLIST_FILE = "ZFModalTransitionDemoTests/ZFModalTransitionDemoTests-Info.plist"; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | TEST_HOST = "$(BUNDLE_LOADER)"; 438 | WRAPPER_EXTENSION = xctest; 439 | }; 440 | name = Debug; 441 | }; 442 | DCAD9987193F6E7300F0F385 /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ZFModalTransitionDemo.app/ZFModalTransitionDemo"; 446 | FRAMEWORK_SEARCH_PATHS = ( 447 | "$(SDKROOT)/Developer/Library/Frameworks", 448 | "$(inherited)", 449 | "$(DEVELOPER_FRAMEWORKS_DIR)", 450 | ); 451 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 452 | GCC_PREFIX_HEADER = "ZFModalTransitionDemo/ZFModalTransitionDemo-Prefix.pch"; 453 | INFOPLIST_FILE = "ZFModalTransitionDemoTests/ZFModalTransitionDemoTests-Info.plist"; 454 | PRODUCT_NAME = "$(TARGET_NAME)"; 455 | TEST_HOST = "$(BUNDLE_LOADER)"; 456 | WRAPPER_EXTENSION = xctest; 457 | }; 458 | name = Release; 459 | }; 460 | /* End XCBuildConfiguration section */ 461 | 462 | /* Begin XCConfigurationList section */ 463 | DCAD994B193F6E7200F0F385 /* Build configuration list for PBXProject "ZFModalTransitionDemo" */ = { 464 | isa = XCConfigurationList; 465 | buildConfigurations = ( 466 | DCAD9980193F6E7300F0F385 /* Debug */, 467 | DCAD9981193F6E7300F0F385 /* Release */, 468 | ); 469 | defaultConfigurationIsVisible = 0; 470 | defaultConfigurationName = Release; 471 | }; 472 | DCAD9982193F6E7300F0F385 /* Build configuration list for PBXNativeTarget "ZFModalTransitionDemo" */ = { 473 | isa = XCConfigurationList; 474 | buildConfigurations = ( 475 | DCAD9983193F6E7300F0F385 /* Debug */, 476 | DCAD9984193F6E7300F0F385 /* Release */, 477 | ); 478 | defaultConfigurationIsVisible = 0; 479 | defaultConfigurationName = Release; 480 | }; 481 | DCAD9985193F6E7300F0F385 /* Build configuration list for PBXNativeTarget "ZFModalTransitionDemoTests" */ = { 482 | isa = XCConfigurationList; 483 | buildConfigurations = ( 484 | DCAD9986193F6E7300F0F385 /* Debug */, 485 | DCAD9987193F6E7300F0F385 /* Release */, 486 | ); 487 | defaultConfigurationIsVisible = 0; 488 | defaultConfigurationName = Release; 489 | }; 490 | /* End XCConfigurationList section */ 491 | }; 492 | rootObject = DCAD9948193F6E7200F0F385 /* Project object */; 493 | } 494 | -------------------------------------------------------------------------------- /ZFDragableModalTransition/ZFModalTransitionAnimator.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZFModalTransitionAnimator.m 3 | // 4 | // Created by Amornchai Kanokpullwad on 5/10/14. 5 | // Copyright (c) 2014 zoonref. All rights reserved. 6 | // 7 | 8 | #import "ZFModalTransitionAnimator.h" 9 | 10 | @interface ZFModalTransitionAnimator () 11 | @property (nonatomic, weak) UIViewController *modalController; 12 | @property (nonatomic, strong) ZFDetectScrollViewEndGestureRecognizer *gesture; 13 | @property (nonatomic, strong) id transitionContext; 14 | @property CGFloat panLocationStart; 15 | @property BOOL isDismiss; 16 | @property BOOL isInteractive; 17 | @property CATransform3D tempTransform; 18 | @end 19 | 20 | @implementation ZFModalTransitionAnimator 21 | 22 | - (instancetype)initWithModalViewController:(UIViewController *)modalViewController 23 | { 24 | self = [super init]; 25 | if (self) { 26 | _modalController = modalViewController; 27 | _direction = ZFModalTransitonDirectionBottom; 28 | _dragable = NO; 29 | _bounces = YES; 30 | _behindViewScale = 0.9f; 31 | _behindViewAlpha = 1.0f; 32 | _transitionDuration = 0.8f; 33 | 34 | [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 35 | [[NSNotificationCenter defaultCenter] addObserver:self 36 | selector:@selector(orientationChanged:) 37 | name:UIApplicationDidChangeStatusBarFrameNotification 38 | object:nil]; 39 | } 40 | return self; 41 | } 42 | 43 | - (void)dealloc 44 | { 45 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 46 | [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; 47 | } 48 | 49 | - (void)setDragable:(BOOL)dragable 50 | { 51 | _dragable = dragable; 52 | if (_dragable) { 53 | [self removeGestureRecognizerFromModalController]; 54 | self.gesture = [[ZFDetectScrollViewEndGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; 55 | self.gesture.delegate = self; 56 | [self.modalController.view addGestureRecognizer:self.gesture]; 57 | } else { 58 | [self removeGestureRecognizerFromModalController]; 59 | } 60 | } 61 | 62 | - (void)setContentScrollView:(UIScrollView *)scrollView 63 | { 64 | // always enable drag if scrollview is set 65 | if (!self.dragable) { 66 | self.dragable = YES; 67 | } 68 | // and scrollview will work only for bottom mode 69 | self.direction = ZFModalTransitonDirectionBottom; 70 | self.gesture.scrollview = scrollView; 71 | } 72 | 73 | - (void)setDirection:(ZFModalTransitonDirection)direction 74 | { 75 | _direction = direction; 76 | // scrollview will work only for bottom mode 77 | if (_direction != ZFModalTransitonDirectionBottom) { 78 | self.gesture.scrollview = nil; 79 | } 80 | } 81 | 82 | - (void)animationEnded:(BOOL)transitionCompleted 83 | { 84 | // Reset to our default state 85 | self.isInteractive = NO; 86 | self.transitionContext = nil; 87 | } 88 | 89 | - (NSTimeInterval)transitionDuration:(id)transitionContext 90 | { 91 | return self.transitionDuration; 92 | } 93 | 94 | - (void)animateTransition:(id)transitionContext 95 | { 96 | if (self.isInteractive) { 97 | return; 98 | } 99 | // Grab the from and to view controllers from the context 100 | UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 101 | UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 102 | 103 | UIView *containerView = [transitionContext containerView]; 104 | 105 | if (!self.isDismiss) { 106 | 107 | CGRect startRect; 108 | 109 | [containerView addSubview:toViewController.view]; 110 | 111 | toViewController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 112 | 113 | if (self.direction == ZFModalTransitonDirectionBottom) { 114 | startRect = CGRectMake(0, 115 | CGRectGetHeight(containerView.frame), 116 | CGRectGetWidth(containerView.bounds), 117 | CGRectGetHeight(containerView.bounds)); 118 | } else if (self.direction == ZFModalTransitonDirectionLeft) { 119 | startRect = CGRectMake(-CGRectGetWidth(containerView.frame), 120 | 0, 121 | CGRectGetWidth(containerView.bounds), 122 | CGRectGetHeight(containerView.bounds)); 123 | } else if (self.direction == ZFModalTransitonDirectionRight) { 124 | startRect = CGRectMake(CGRectGetWidth(containerView.frame), 125 | 0, 126 | CGRectGetWidth(containerView.bounds), 127 | CGRectGetHeight(containerView.bounds)); 128 | } 129 | 130 | CGPoint transformedPoint = CGPointApplyAffineTransform(startRect.origin, toViewController.view.transform); 131 | toViewController.view.frame = CGRectMake(transformedPoint.x, transformedPoint.y, startRect.size.width, startRect.size.height); 132 | 133 | if (toViewController.modalPresentationStyle == UIModalPresentationCustom) { 134 | [fromViewController beginAppearanceTransition:NO animated:YES]; 135 | } 136 | 137 | [UIView animateWithDuration:[self transitionDuration:transitionContext] 138 | delay:0 139 | usingSpringWithDamping:0.8 140 | initialSpringVelocity:0.1 141 | options:UIViewAnimationOptionCurveEaseOut 142 | animations:^{ 143 | fromViewController.view.transform = CGAffineTransformScale(fromViewController.view.transform, self.behindViewScale, self.behindViewScale); 144 | fromViewController.view.alpha = self.behindViewAlpha; 145 | 146 | toViewController.view.frame = CGRectMake(0,0, 147 | CGRectGetWidth(toViewController.view.frame), 148 | CGRectGetHeight(toViewController.view.frame)); 149 | } completion:^(BOOL finished) { 150 | if (toViewController.modalPresentationStyle == UIModalPresentationCustom) { 151 | [fromViewController endAppearanceTransition]; 152 | } 153 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; 154 | }]; 155 | } else { 156 | 157 | if (fromViewController.modalPresentationStyle == UIModalPresentationFullScreen) { 158 | [containerView addSubview:toViewController.view]; 159 | } 160 | 161 | [containerView bringSubviewToFront:fromViewController.view]; 162 | 163 | if (![self isPriorToIOS8]) { 164 | toViewController.view.layer.transform = CATransform3DScale(toViewController.view.layer.transform, self.behindViewScale, self.behindViewScale, 1); 165 | } 166 | 167 | toViewController.view.alpha = self.behindViewAlpha; 168 | 169 | CGRect endRect; 170 | 171 | if (self.direction == ZFModalTransitonDirectionBottom) { 172 | endRect = CGRectMake(0, 173 | CGRectGetHeight(fromViewController.view.bounds), 174 | CGRectGetWidth(fromViewController.view.frame), 175 | CGRectGetHeight(fromViewController.view.frame)); 176 | } else if (self.direction == ZFModalTransitonDirectionLeft) { 177 | endRect = CGRectMake(-CGRectGetWidth(fromViewController.view.bounds), 178 | 0, 179 | CGRectGetWidth(fromViewController.view.frame), 180 | CGRectGetHeight(fromViewController.view.frame)); 181 | } else if (self.direction == ZFModalTransitonDirectionRight) { 182 | endRect = CGRectMake(CGRectGetWidth(fromViewController.view.bounds), 183 | 0, 184 | CGRectGetWidth(fromViewController.view.frame), 185 | CGRectGetHeight(fromViewController.view.frame)); 186 | } 187 | 188 | CGPoint transformedPoint = CGPointApplyAffineTransform(endRect.origin, fromViewController.view.transform); 189 | endRect = CGRectMake(transformedPoint.x, transformedPoint.y, endRect.size.width, endRect.size.height); 190 | 191 | if (fromViewController.modalPresentationStyle == UIModalPresentationCustom) { 192 | [toViewController beginAppearanceTransition:YES animated:YES]; 193 | } 194 | 195 | [UIView animateWithDuration:[self transitionDuration:transitionContext] 196 | delay:0 197 | usingSpringWithDamping:0.8 198 | initialSpringVelocity:0.1 199 | options:UIViewAnimationOptionCurveEaseOut 200 | animations:^{ 201 | CGFloat scaleBack = (1 / self.behindViewScale); 202 | toViewController.view.layer.transform = CATransform3DScale(toViewController.view.layer.transform, scaleBack, scaleBack, 1); 203 | toViewController.view.alpha = 1.0f; 204 | fromViewController.view.frame = endRect; 205 | } completion:^(BOOL finished) { 206 | toViewController.view.layer.transform = CATransform3DIdentity; 207 | if (fromViewController.modalPresentationStyle == UIModalPresentationCustom) { 208 | [toViewController endAppearanceTransition]; 209 | } 210 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; 211 | }]; 212 | } 213 | } 214 | 215 | - (void)removeGestureRecognizerFromModalController 216 | { 217 | if (self.gesture && [self.modalController.view.gestureRecognizers containsObject:self.gesture]) { 218 | [self.modalController.view removeGestureRecognizer:self.gesture]; 219 | self.gesture = nil; 220 | } 221 | } 222 | 223 | # pragma mark - Gesture 224 | 225 | - (void)handlePan:(UIPanGestureRecognizer *)recognizer 226 | { 227 | // Location reference 228 | CGPoint location = [recognizer locationInView:self.modalController.view.window]; 229 | location = CGPointApplyAffineTransform(location, CGAffineTransformInvert(recognizer.view.transform)); 230 | // Velocity reference 231 | CGPoint velocity = [recognizer velocityInView:[self.modalController.view window]]; 232 | velocity = CGPointApplyAffineTransform(velocity, CGAffineTransformInvert(recognizer.view.transform)); 233 | 234 | if (recognizer.state == UIGestureRecognizerStateBegan) { 235 | self.isInteractive = YES; 236 | if (self.direction == ZFModalTransitonDirectionBottom) { 237 | self.panLocationStart = location.y; 238 | } else { 239 | self.panLocationStart = location.x; 240 | } 241 | [self.modalController dismissViewControllerAnimated:YES completion:nil]; 242 | 243 | } else if (recognizer.state == UIGestureRecognizerStateChanged) { 244 | CGFloat animationRatio = 0; 245 | 246 | if (self.direction == ZFModalTransitonDirectionBottom) { 247 | animationRatio = (location.y - self.panLocationStart) / (CGRectGetHeight([self.modalController view].bounds)); 248 | } else if (self.direction == ZFModalTransitonDirectionLeft) { 249 | animationRatio = (self.panLocationStart - location.x) / (CGRectGetWidth([self.modalController view].bounds)); 250 | } else if (self.direction == ZFModalTransitonDirectionRight) { 251 | animationRatio = (location.x - self.panLocationStart) / (CGRectGetWidth([self.modalController view].bounds)); 252 | } 253 | 254 | [self updateInteractiveTransition:animationRatio]; 255 | 256 | } else if (recognizer.state == UIGestureRecognizerStateEnded) { 257 | 258 | CGFloat velocityForSelectedDirection; 259 | 260 | if (self.direction == ZFModalTransitonDirectionBottom) { 261 | velocityForSelectedDirection = velocity.y; 262 | } else { 263 | velocityForSelectedDirection = velocity.x; 264 | } 265 | 266 | if (velocityForSelectedDirection > 100 267 | && (self.direction == ZFModalTransitonDirectionRight 268 | || self.direction == ZFModalTransitonDirectionBottom)) { 269 | [self finishInteractiveTransition]; 270 | } else if (velocityForSelectedDirection < -100 && self.direction == ZFModalTransitonDirectionLeft) { 271 | [self finishInteractiveTransition]; 272 | } else { 273 | [self cancelInteractiveTransition]; 274 | } 275 | self.isInteractive = NO; 276 | } 277 | } 278 | 279 | #pragma mark - 280 | 281 | -(void)startInteractiveTransition:(id)transitionContext 282 | { 283 | self.transitionContext = transitionContext; 284 | 285 | UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 286 | UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 287 | 288 | if (![self isPriorToIOS8]) { 289 | toViewController.view.layer.transform = CATransform3DScale(toViewController.view.layer.transform, self.behindViewScale, self.behindViewScale, 1); 290 | } 291 | 292 | self.tempTransform = toViewController.view.layer.transform; 293 | 294 | toViewController.view.alpha = self.behindViewAlpha; 295 | 296 | if (fromViewController.modalPresentationStyle == UIModalPresentationFullScreen) { 297 | [[transitionContext containerView] addSubview:toViewController.view]; 298 | } 299 | [[transitionContext containerView] bringSubviewToFront:fromViewController.view]; 300 | } 301 | 302 | - (void)updateInteractiveTransition:(CGFloat)percentComplete 303 | { 304 | if (!self.bounces && percentComplete < 0) { 305 | percentComplete = 0; 306 | } 307 | 308 | id transitionContext = self.transitionContext; 309 | 310 | UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 311 | UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 312 | CATransform3D transform = CATransform3DMakeScale( 313 | 1 + (((1 / self.behindViewScale) - 1) * percentComplete), 314 | 1 + (((1 / self.behindViewScale) - 1) * percentComplete), 1); 315 | toViewController.view.layer.transform = CATransform3DConcat(self.tempTransform, transform); 316 | 317 | toViewController.view.alpha = self.behindViewAlpha + ((1 - self.behindViewAlpha) * percentComplete); 318 | 319 | CGRect updateRect; 320 | if (self.direction == ZFModalTransitonDirectionBottom) { 321 | updateRect = CGRectMake(0, 322 | (CGRectGetHeight(fromViewController.view.bounds) * percentComplete), 323 | CGRectGetWidth(fromViewController.view.frame), 324 | CGRectGetHeight(fromViewController.view.frame)); 325 | } else if (self.direction == ZFModalTransitonDirectionLeft) { 326 | updateRect = CGRectMake(-(CGRectGetWidth(fromViewController.view.bounds) * percentComplete), 327 | 0, 328 | CGRectGetWidth(fromViewController.view.frame), 329 | CGRectGetHeight(fromViewController.view.frame)); 330 | } else if (self.direction == ZFModalTransitonDirectionRight) { 331 | updateRect = CGRectMake(CGRectGetWidth(fromViewController.view.bounds) * percentComplete, 332 | 0, 333 | CGRectGetWidth(fromViewController.view.frame), 334 | CGRectGetHeight(fromViewController.view.frame)); 335 | } 336 | 337 | // reset to zero if x and y has unexpected value to prevent crash 338 | if (isnan(updateRect.origin.x) || isinf(updateRect.origin.x)) { 339 | updateRect.origin.x = 0; 340 | } 341 | if (isnan(updateRect.origin.y) || isinf(updateRect.origin.y)) { 342 | updateRect.origin.y = 0; 343 | } 344 | 345 | CGPoint transformedPoint = CGPointApplyAffineTransform(updateRect.origin, fromViewController.view.transform); 346 | updateRect = CGRectMake(transformedPoint.x, transformedPoint.y, updateRect.size.width, updateRect.size.height); 347 | 348 | fromViewController.view.frame = updateRect; 349 | } 350 | 351 | - (void)finishInteractiveTransition 352 | { 353 | id transitionContext = self.transitionContext; 354 | 355 | UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 356 | UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 357 | 358 | CGRect endRect; 359 | 360 | if (self.direction == ZFModalTransitonDirectionBottom) { 361 | endRect = CGRectMake(0, 362 | CGRectGetHeight(fromViewController.view.bounds), 363 | CGRectGetWidth(fromViewController.view.frame), 364 | CGRectGetHeight(fromViewController.view.frame)); 365 | } else if (self.direction == ZFModalTransitonDirectionLeft) { 366 | endRect = CGRectMake(-CGRectGetWidth(fromViewController.view.bounds), 367 | 0, 368 | CGRectGetWidth(fromViewController.view.frame), 369 | CGRectGetHeight(fromViewController.view.frame)); 370 | } else if (self.direction == ZFModalTransitonDirectionRight) { 371 | endRect = CGRectMake(CGRectGetWidth(fromViewController.view.bounds), 372 | 0, 373 | CGRectGetWidth(fromViewController.view.frame), 374 | CGRectGetHeight(fromViewController.view.frame)); 375 | } 376 | 377 | CGPoint transformedPoint = CGPointApplyAffineTransform(endRect.origin, fromViewController.view.transform); 378 | endRect = CGRectMake(transformedPoint.x, transformedPoint.y, endRect.size.width, endRect.size.height); 379 | 380 | if (fromViewController.modalPresentationStyle == UIModalPresentationCustom) { 381 | [toViewController beginAppearanceTransition:YES animated:YES]; 382 | } 383 | 384 | [UIView animateWithDuration:[self transitionDuration:transitionContext] 385 | delay:0 386 | usingSpringWithDamping:0.8 387 | initialSpringVelocity:0.1 388 | options:UIViewAnimationOptionCurveEaseOut 389 | animations:^{ 390 | CGFloat scaleBack = (1 / self.behindViewScale); 391 | toViewController.view.layer.transform = CATransform3DScale(self.tempTransform, scaleBack, scaleBack, 1); 392 | toViewController.view.alpha = 1.0f; 393 | fromViewController.view.frame = endRect; 394 | } completion:^(BOOL finished) { 395 | if (fromViewController.modalPresentationStyle == UIModalPresentationCustom) { 396 | [toViewController endAppearanceTransition]; 397 | } 398 | [transitionContext completeTransition:YES]; 399 | }]; 400 | } 401 | 402 | - (void)cancelInteractiveTransition 403 | { 404 | id transitionContext = self.transitionContext; 405 | [transitionContext cancelInteractiveTransition]; 406 | 407 | UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 408 | UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 409 | 410 | [UIView animateWithDuration:0.4 411 | delay:0 412 | usingSpringWithDamping:0.8 413 | initialSpringVelocity:0.1 414 | options:UIViewAnimationOptionCurveEaseOut 415 | animations:^{ 416 | toViewController.view.layer.transform = self.tempTransform; 417 | toViewController.view.alpha = self.behindViewAlpha; 418 | 419 | fromViewController.view.frame = CGRectMake(0,0, 420 | CGRectGetWidth(fromViewController.view.frame), 421 | CGRectGetHeight(fromViewController.view.frame)); 422 | } completion:^(BOOL finished) { 423 | [transitionContext completeTransition:NO]; 424 | if (fromViewController.modalPresentationStyle == UIModalPresentationFullScreen) { 425 | [toViewController.view removeFromSuperview]; 426 | } 427 | }]; 428 | } 429 | 430 | #pragma mark - UIViewControllerTransitioningDelegate Methods 431 | 432 | - (id )animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source 433 | { 434 | self.isDismiss = NO; 435 | return self; 436 | } 437 | 438 | - (id )animationControllerForDismissedController:(UIViewController *)dismissed 439 | { 440 | self.isDismiss = YES; 441 | return self; 442 | } 443 | 444 | - (id )interactionControllerForPresentation:(id )animator 445 | { 446 | return nil; 447 | } 448 | 449 | - (id )interactionControllerForDismissal:(id )animator 450 | { 451 | // Return nil if we are not interactive 452 | if (self.isInteractive && self.dragable) { 453 | self.isDismiss = YES; 454 | return self; 455 | } 456 | 457 | return nil; 458 | } 459 | 460 | #pragma mark - Gesture Delegate 461 | 462 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 463 | { 464 | if (self.direction == ZFModalTransitonDirectionBottom) { 465 | return YES; 466 | } 467 | return NO; 468 | } 469 | 470 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 471 | { 472 | if (self.direction == ZFModalTransitonDirectionBottom) { 473 | return YES; 474 | } 475 | return NO; 476 | } 477 | 478 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { 479 | if (self.gestureRecognizerToFailPan && otherGestureRecognizer && self.gestureRecognizerToFailPan == otherGestureRecognizer) { 480 | return YES; 481 | } 482 | 483 | return NO; 484 | } 485 | 486 | #pragma mark - Utils 487 | 488 | - (BOOL)isPriorToIOS8 489 | { 490 | NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"8.0" options: NSNumericSearch]; 491 | if (order == NSOrderedSame || order == NSOrderedDescending) { 492 | // OS version >= 8.0 493 | return YES; 494 | } 495 | return NO; 496 | } 497 | 498 | #pragma mark - Orientation 499 | 500 | - (void)orientationChanged:(NSNotification *)notification 501 | { 502 | UIViewController *backViewController = self.modalController.presentingViewController; 503 | backViewController.view.transform = CGAffineTransformIdentity; 504 | backViewController.view.frame = self.modalController.view.bounds; 505 | backViewController.view.transform = CGAffineTransformScale(backViewController.view.transform, self.behindViewScale, self.behindViewScale); 506 | } 507 | 508 | @end 509 | 510 | // Gesture Class Implement 511 | @interface ZFDetectScrollViewEndGestureRecognizer () 512 | @property (nonatomic, strong) NSNumber *isFail; 513 | @end 514 | 515 | @implementation ZFDetectScrollViewEndGestureRecognizer 516 | 517 | - (void)reset 518 | { 519 | [super reset]; 520 | self.isFail = nil; 521 | } 522 | 523 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 524 | { 525 | [super touchesMoved:touches withEvent:event]; 526 | 527 | if (!self.scrollview) { 528 | return; 529 | } 530 | 531 | if (self.state == UIGestureRecognizerStateFailed) return; 532 | CGPoint velocity = [self velocityInView:self.view]; 533 | CGPoint nowPoint = [touches.anyObject locationInView:self.view]; 534 | CGPoint prevPoint = [touches.anyObject previousLocationInView:self.view]; 535 | 536 | if (self.isFail) { 537 | if (self.isFail.boolValue) { 538 | self.state = UIGestureRecognizerStateFailed; 539 | } 540 | return; 541 | } 542 | 543 | CGFloat topVerticalOffset = -self.scrollview.contentInset.top; 544 | 545 | if ((fabs(velocity.x) < fabs(velocity.y)) && (nowPoint.y > prevPoint.y) && (self.scrollview.contentOffset.y <= topVerticalOffset)) { 546 | self.isFail = @NO; 547 | } else if (self.scrollview.contentOffset.y >= topVerticalOffset) { 548 | self.state = UIGestureRecognizerStateFailed; 549 | self.isFail = @YES; 550 | } else { 551 | self.isFail = @NO; 552 | } 553 | } 554 | 555 | @end 556 | --------------------------------------------------------------------------------