TransEasy 0.8.0

TransEasy 0.8.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2016 年 10 月
SPM支持 SPM

M. Porooshani 维护。



TransEasy 0.8.0

  • 作者:
  • M. Porooshani

TransEasy

一个易于实现的定制过渡。

demo

概述

这个库将帮助您轻松定制过渡(模态和推送),以便您可以将视图从一个移动到另一个。


如何设置

手册

克隆或下载此仓库,将 Source 文件夹中的文件添加到您的项目中。


如何使用

真正简单的方法

在此方法中,您将非常容易地使用简单的方法设置 EasyTrans,并将其用于推送过渡和模态演示。

 func next() {

    guard let destinationViewController = storyboard?.instantiateViewControllerWithIdentifier("secondVC") else {
      return
    }
    // This method adds easy trans to the SecondViewController using the provided options for present and dismiss.

    setupEasyTransition(on: destinationViewController, presentOptions: TransEasyPresentOptions(duration: 0.4, sourceView: qrButton, blurStyle: UIBlurEffectStyle.Dark), dismissOptions: TransEasyDismissOptions(duration: 0.4, destinationView: qrButton, interactive: true))

    if modal {
      presentViewController(destinationViewController, animated: true, completion: nil)
    } else {
      performSegueWithIdentifier(toSecondViewSegueID, sender: sender)
    }

  }

在目标视图控制器中

extension SecondViewController: TransEasyDestinationViewControllerProtocol {

  func transEasyDestinationView() -> UIView {
    return qrImage
  }

}

并且为了能够在源视图控制器中使用 TransEasy 进行弹出过渡

func transEasyDestinationView() -> UIView {
    return qrButton
  }

不易的方法(仅模态演示)

或者,您可以自己实现 transitioningDelegate 并仅使用动画控制器。

  • 在您的视图控制器中添加必要的属性以保存动画器
    let presentAnimator: EasyPresentAnimationController = EasyPresentAnimationController()
    let dismissAnimator: EasyDismissAnimationController = EasyDismissAnimationController()    
  • prepareForSegue 中设置 transitioningDelegate
segue.destinationViewController.transitioningDelegate = self

  • 扩展您的视图控制器以使用 TransEasy 过渡

    extension ViewController: UIViewControllerTransitioningDelegate {
    
       func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    
           guard let secondVC = presented as? SecondViewController else {
               return nil
           }
    
           presentAnimator.duration = 0.4
           presentAnimator.originalView = qrButton
           presentAnimator.destinationView = secondVC.qrImage
           presentAnimator.blurEffectStyle = .Dark
    
    
           return presentAnimator
       }
    
       func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    
           guard let secondVC = dismissed as? SecondViewController else {
               return nil
           }
           dismissAnimator.duration = 0.4
           dismissAnimator.originalView = secondVC.qrImage
           dismissAnimator.destinationView = qrButton
    
           return dismissAnimator
       }
    
    }
    


待办事项

  • [x] 设置项目的基本结构。
  • [x] 创建演示视图并建立关系。
  • [x] 创建所需的类和协议。
  • [x] 添加许可证文件。
  • [x] 添加文档。
  • [x] 添加截图。
  • [ ] 添加 CI。
  • [x] 添加 Pod 支持。
  • [ ] 使过渡交互式。
  • [ ] 使弹出动画与原始动画匹配。
  • [ ] 为模态演示添加过渡选项。
  • [ ] 为过渡添加代理对象和事件。