This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UpToDownIneraction: UIPercentDrivenInteractiveTransition { | |
// ... | |
func wireGesture(on viewController: UIViewController) { | |
presentingViewController = viewController | |
let gesture = UIPanGestureRecognizer(target: self, action: #selector(handleGesture(_:))) | |
viewController.view.addGestureRecognizer(gesture) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UpToDownIneraction: UIPercentDrivenInteractiveTransition { | |
var interacting: Bool = false | |
private var couldComplete: Bool = false | |
private weak var presentingViewController: UIViewController? = nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomTransition: NSObject, UIViewControllerTransitioningDelegate { | |
// ... | |
let interaction = UpToDownIneraction() | |
func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { | |
return nil | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrepareToPushViewController: UIViewController { | |
let button = UIButton(type: .system) | |
let animation = CustomTransition() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// set view layout | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomDismissAnimation: NSObject , UIViewControllerAnimatedTransitioning { | |
let endPoint: CGPoint | |
var grayView: UIView! | |
private let durationTime = 0.45 | |
init(endPoint: CGPoint) { | |
self.endPoint = endPoint | |
super.init() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
// 取出 toView, 在上面的示意圖中代表的就是 A 畫面 | |
guard let toView = transitionContext.viewController(forKey: .to)?.view else { | |
return | |
} | |
// 取出 container view | |
let containerView = transitionContext.containerView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomPresentAnimation: NSObject , UIViewControllerAnimatedTransitioning { | |
var startPoint: CGPoint // 擴散的起始點 | |
private let durationTime = 0.45 // 動畫時間 | |
init(startPoint: CGPoint) { | |
self.startPoint = startPoint | |
super.init() | |
} | |
NewerOlder