Skip to content

Instantly share code, notes, and snippets.

View ohlulu's full-sized avatar
😎
happy test happy deliver

ohlulu ohlulu

😎
happy test happy deliver
View GitHub Profile
class UpToDownIneraction: UIPercentDrivenInteractiveTransition {
// ...
func wireGesture(on viewController: UIViewController) {
presentingViewController = viewController
let gesture = UIPanGestureRecognizer(target: self, action: #selector(handleGesture(_:)))
viewController.view.addGestureRecognizer(gesture)
}
class UpToDownIneraction: UIPercentDrivenInteractiveTransition {
var interacting: Bool = false
private var couldComplete: Bool = false
private weak var presentingViewController: UIViewController? = nil
}
@ohlulu
ohlulu / 6.swift
Last active September 10, 2019 07:53
class CustomTransition: NSObject, UIViewControllerTransitioningDelegate {
// ...
let interaction = UpToDownIneraction()
func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return nil
}
class PrepareToPushViewController: UIViewController {
let button = UIButton(type: .system)
let animation = CustomTransition()
override func viewDidLoad() {
super.viewDidLoad()
// set view layout
}
}
class CustomDismissAnimation: NSObject , UIViewControllerAnimatedTransitioning {
let endPoint: CGPoint
var grayView: UIView!
private let durationTime = 0.45
init(endPoint: CGPoint) {
self.endPoint = endPoint
super.init()
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
// 取出 toView, 在上面的示意圖中代表的就是 A 畫面
guard let toView = transitionContext.viewController(forKey: .to)?.view else {
return
}
// 取出 container view
let containerView = transitionContext.containerView
class CustomPresentAnimation: NSObject , UIViewControllerAnimatedTransitioning {
var startPoint: CGPoint // 擴散的起始點
private let durationTime = 0.45 // 動畫時間
init(startPoint: CGPoint) {
self.startPoint = startPoint
super.init()
}