AnimatedTransition

@MainActor
open class AnimatedTransition: UIPercentDrivenInteractiveTransition,
    UIViewControllerAnimatedTransitioning,
    UIViewControllerTransitioningDelegate,
    UINavigationControllerDelegate

转场动画类,默认透明度变化

Transition

  • 创建系统转场单例,不支持交互手势转场

    Declaration

    Swift

    @MainActor
    public static let system: AnimatedTransition
  • 设置动画句柄

    Declaration

    Swift

    @MainActor
    open var transitionBlock: ((AnimatedTransition) -> Void)?
  • 动画持续时间,必须大于0,默认同completionSpeed为0.35秒

    Declaration

    Swift

    @MainActor
    open var transitionDuration: TimeInterval
  • 获取动画类型,默认根据上下文判断

    Declaration

    Swift

    @MainActor
    open var transitionType: AnimatedTransitionType { get set }
  • 创建动画转场

    Declaration

    Swift

    @MainActor
    override public init()
  • 创建动画句柄转场

    Declaration

    Swift

    @MainActor
    public convenience init(block: (@MainActor @Sendable (AnimatedTransition) -> Void)?)

Interactive

  • 是否启用交互pan手势进行pop|dismiss,默认false。可使用父类属性设置交互动画

    Declaration

    Swift

    @MainActor
    open var interactEnabled: Bool { get set }
  • 指定与滚动视图pan手势的冲突交互方向,默认向下

    Declaration

    Swift

    @MainActor
    open var interactDirection: UISwipeGestureRecognizer.Direction { get set }
  • 是否启用screenEdge交互手势进行pop|dismiss,默认false。与gestureRecognizer可共存

    Declaration

    Swift

    @MainActor
    open var interactScreenEdge: Bool { get set }
  • 是否正在交互中,手势开始才会标记为YES,手势结束标记为NO

    Declaration

    Swift

    @MainActor
    open private(set) var isInteracting: Bool { get }
  • 是否正在以交互方式dismiss|pop,需开启交互pan手势或screenEdge手势

    Declaration

    Swift

    @MainActor
    open private(set) var isInteractDismissing: Bool { get }
  • 自定义交互句柄,可根据手势state处理不同状态的交互,返回YES执行默认交互,返回NO不执行。默认为空,执行默认交互

    Declaration

    Swift

    @MainActor
    open var interactBlock: ((UIPanGestureRecognizer) -> Bool)?
  • 自定义交互时dismiss关闭动画完成回调(仅交互才会触发),默认nil

    Declaration

    Swift

    @MainActor
    open var interactDismissCompletion: (() -> Void)?
  • 自定义dismiss关闭动画完成回调(交互和非交互都会触发),默认nil

    Declaration

    Swift

    @MainActor
    open var dismissCompletion: (() -> Void)?
  • 当前交互pan手势对象,默认PanGestureRecognizer,可设置交互方向,滚动视图等

    Declaration

    Swift

    @MainActor
    open var gestureRecognizer: UIPanGestureRecognizer { get set }
  • 当前交互screenEdge手势对象,可设置交互边,默认left

    Declaration

    Swift

    @MainActor
    open var screenEdgeGestureRecognizer: UIScreenEdgePanGestureRecognizer { get set }
  • 手工绑定交互控制器,添加pan手势或screenEdge手势,需要vc.view存在时调用才生效。默认自动绑定,如果自定义interactBlock,必须手工绑定

    Declaration

    Swift

    @MainActor
    open func interact(with viewController: UIViewController)

Presentation

  • 是否启用默认展示控制器,启用后自动设置presentationBlock返回PresentationController,默认false

    Declaration

    Swift

    @MainActor
    open var presentationEnabled: Bool { get set }
  • 设置展示控制器创建句柄,自定义弹出效果。present时建议设置modalPresentationStyle为Custom

    Declaration

    Swift

    @MainActor
    open var presentationBlock: ((UIViewController, UIViewController?) -> UIPresentationController)?

UIViewControllerTransitioningDelegate

  • Undocumented

    Declaration

    Swift

    @MainActor
    open func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?

UINavigationControllerDelegate

  • Undocumented

    Declaration

    Swift

    @MainActor
    open func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?

UIViewControllerAnimatedTransitioning

  • Undocumented

    Declaration

    Swift

    @MainActor
    open func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
  • Undocumented

    Declaration

    Swift

    @MainActor
    open func animateTransition(using transitionContext: UIViewControllerContextTransitioning)

Animate

  • 转场上下文,只读

    Declaration

    Swift

    @MainActor
    open private(set) weak var transitionContext: UIViewControllerContextTransitioning? { get }
  • 标记动画开始(自动添加视图到容器)

    Declaration

    Swift

    @MainActor
    open func start()
  • 执行动画,子类重写,可选

    Declaration

    Swift

    @MainActor
    open func animate()
  • 自动标记动画完成(根据transitionContext是否被取消判断)

    Declaration

    Swift

    @MainActor
    open func complete()