-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
|
||
// | ||
// BaseNavigationController.swift | ||
// BottomBar | ||
// | ||
// Created by 全达晖 on 2020/9/20. | ||
// Copyright © 2020 全达晖. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class BaseNavigationController: UINavigationController, UINavigationControllerDelegate { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
self.delegate = self | ||
} | ||
|
||
// 非手势交互转场 | ||
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { | ||
if operation == .push { | ||
return PushAnimatedTransitionAsFromBottomToTop.init() | ||
} else if (operation == .pop) { | ||
return PopAnimatedTransitioningAsFromTopToBottom.init() | ||
} | ||
return nil | ||
} | ||
|
||
// 手势交互转场 | ||
func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { | ||
return nil | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// PopAnimatedTransitioningAsFromTopToBottom.swift | ||
// BottomBar | ||
// | ||
// Created by 全达晖 on 2020/9/20. | ||
// Copyright © 2020 全达晖. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class PopAnimatedTransitioningAsFromTopToBottom: NSObject, UIViewControllerAnimatedTransitioning { | ||
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { | ||
return 0.35 | ||
} | ||
|
||
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | ||
let toVC = transitionContext.viewController(forKey: .to) | ||
let fromVC = transitionContext.viewController(forKey: .from) | ||
|
||
let toView: UIView! | ||
let fromView: UIView! | ||
|
||
if transitionContext.responds(to: #selector(transitionContext.view(forKey:))) { | ||
toView = transitionContext.view(forKey: .to) | ||
fromView = transitionContext.view(forKey: .from) | ||
} else { | ||
fromView = fromVC?.view | ||
toView = toVC?.view | ||
} | ||
transitionContext.containerView.insertSubview(toView, belowSubview: fromView) | ||
|
||
fromView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) | ||
|
||
UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: .curveEaseInOut, animations: { | ||
fromView.frame = CGRect.init(x: 0, y: screenHeight, width: screenWidth, height: screenHeight) | ||
}) { (finish) in | ||
transitionContext.completeTransition(true) | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// PushAnimatedTransitionAsFromBottomToTop.swift | ||
// BottomBar | ||
// | ||
// Created by 全达晖 on 2020/9/20. | ||
// Copyright © 2020 全达晖. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class PushAnimatedTransitionAsFromBottomToTop: NSObject, UIViewControllerAnimatedTransitioning { | ||
|
||
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { | ||
return 0.35 | ||
} | ||
|
||
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | ||
let toVC = transitionContext.viewController(forKey: .to) | ||
let toView: UIView! | ||
|
||
if transitionContext.responds(to: #selector(transitionContext.view(forKey:))) { | ||
toView = transitionContext.view(forKey: .to) | ||
} else { | ||
toView = toVC?.view | ||
} | ||
|
||
let containerView = transitionContext.containerView | ||
containerView.addSubview(toView) | ||
|
||
toView.frame = CGRect.init(x: 0, y: screenHeight, width: screenWidth, height: screenHeight) | ||
|
||
UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: .curveEaseInOut, animations: { | ||
toView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) | ||
}) { (finish) in | ||
transitionContext.completeTransition(true) | ||
} | ||
} | ||
} |
This file contains 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