forked from seedante/SDECollectionViewAlbumTransition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDENavigationControllerDelegate.swift
43 lines (31 loc) · 1.57 KB
/
SDENavigationControllerDelegate.swift
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
//
// SDENavigationDelegate.swift
// SDEAlbumTransition
//
// Created by seedante on 15/10/15.
// Copyright © 2015年 seedante. All rights reserved.
//
import UIKit
class SDENavigationControllerDelegate: NSObject, UINavigationControllerDelegate {
var interactive = false
private (set) var animationController: UIViewControllerAnimatedTransitioning!
private (set) var interactionController: UIPercentDrivenInteractiveTransition?
//MARK: UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
animationController = SDEPushAndPopAnimationController(operation: operation)
if operation == .Push{
if let toCollectionVC = toVC as? UICollectionViewController{
interactionController = SDEPopPinchInteractionController(toVC: toCollectionVC, holder: self)
}
}
return animationController
}
//If you want a interaction transition, you must implement this method.
func navigationController(navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
// interactive can only update in gesture action
if interactive{
return interactionController
}
return nil
}
}