FlipTheBlinds 0.1.1

FlipTheBlinds 0.1.1

测试测试
语言语言 SwiftSwift
许可协议 MIT
发布最后发布2017年1月
SwiftSwift 版本3.0
SPM支持 SPM

Joel Bell 维护。



  • 作者:
  • Joel Bell

FlipTheBlinds

FlipTheBlinds是一种动画过渡,它创建了一个百叶窗多米诺效应。

功能

  • 用于演示、导航和在标签页之间切换的动画过渡。
  • 模态演示可以是编程实现或使用切换实现。
  • 过渡方向和速度可自定义。
  • 专为纵向设备方向设计。
  • Swift 3.0

演示

Screen Capture

要求

  • iOS 8.0+
  • Xcode 10.0+

用法

安装

  pod "FlipTheBlinds"

模态演示

  • 将正在展示的视图控制器的 transitioningDelegate 属性赋给展示视图控制器。
  • 向展示视图控制器添加一个扩展,包含 UIViewControllerTransitioningDelegate 的方法。
  • 使用 FTBAnimationController(displayType:direction:speed:) 返回用于展示和消失的 FTBAnimationController 动画对象实例。
  // MARK: Programmatic option

  func presentAction() {

    let toViewController = ToViewController()
    toViewController.transitioningDelegate = self
    self.present(toViewController, animated: true, completion: nil)

  }

  // MARK: Segue option

  func prepare(for segue: UIStoryboardSegue, sender: Any?) {

      if segue.identifier == "segue", let destinationViewController = segue.destination as? toViewController {

          destinationViewController.transitioningDelegate = self

      }

  }

  // MARK: Transitioning Delegate

  extension fromViewController: UIViewControllerTransitioningDelegate {

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        return FTBAnimationController(displayType: .present, direction: .up, speed: .moderate)

    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        return FTBAnimationController(displayType: .dismiss, direction: .down, speed: .moderate)

    }

  }

导航

  • 将导航控制器的 delegate 属性分配给根视图控制器。
  • 向根视图控制器添加一个扩展,包含 UINavigationControllerDelegate 以及所需的过渡方法。
  • 使用 FTBAnimationController(displayType:direction:speed:) 返回 FTBAnimationController 动画对象实例用于推送和弹出。
  // MARK: Push

  func pushAction() {

      let navStackViewController = NavStackViewController()
      self.navigationController?.delegate = self
      self.navigationController?.pushViewController(navStackViewController, animated: true)

  }

  // MARK: Navigation Controller Delegate

  extension NavRootViewController: UINavigationControllerDelegate {

   func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {

       switch operation {
       case .pop:
           return FTBAnimationController(displayType: .pop, direction: .right, speed: .moderate)
       case .push:
           return FTBAnimationController(displayType: .push, direction: .left, speed: .moderate)
       default:
           return nil
       }

   }

  }

标签栏

  • 将标签栏控制器的 delegate 属性分配给标签栏控制器的其中一个根视图控制器。
  • 向一个根视图控制器添加一个扩展,包含 UITabBarControllerDelegate 和所需的过渡方法。
  • 使用 FTBAnimationController(displayType:direction:speed:) 返回 FTBAnimationController 动画对象实例。
  // MARK: Delegate

  override func viewDidLoad() {
      super.viewDidLoad()

      self.tabBarController?.delegate = self

  }

  // MARK: Tab Bar Controller Delegate

  extension TabBarRootOneViewController: UITabBarControllerDelegate {

      func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {

          return FTBAnimationController(displayType: .tabSelected, direction: .down, speed: .moderate)

      }

  }

已知问题

  • 在模拟器中,动画对象中的绘图/渲染图像存在问题,尤其是在iPhone 7/7P上。建议进行设备测试。
  • drawHierarchy(in:afterScreenUpdates:)用于模态显示,可能会引起不明显的不闪动。

许可证

  • FlipTheBlinds在MIT许可证下发布。详细信息请参阅LICENSE文件。