CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

FlipTheBlinds 0.1.1

FlipTheBlinds 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Joel Bell.



  • By
  • Joel Bell

FlipTheBlinds

FlipTheBlinds is an animation transition that creates a venetian blinds domino effect.

Features

  • Animation transition for use in presentations, navigation, and switching between tabs.
  • Modal presentations can be programmatic or implemented using segues.
  • Transition direction and speed is customizable.
  • Designed for portrait device orientation.
  • Swift 3.0

Demo

Screen Capture

Requirements

  • iOS 8.0+
  • Xcode 10.0+

Usage

Installation

  pod "FlipTheBlinds"

Modal Presentations

  • Assign the transitioningDelegate property of the view controller being presented to the presenting view controller.
  • Add an extension to the presenting view controller that includes methods for the UIViewControllerTransitioningDelegate.
  • Return instances of the FTBAnimationController animator object using FTBAnimationController(displayType:direction:speed:) for presenting and dismissing.
  // 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)

    }

  }

Navigation

  • Assign the delegate property of the navigation controller to the root view controller.
  • Add an extension to the root view controller that includes the UINavigationControllerDelegate and necessary transitioning method.
  • Return instances of the FTBAnimationController animator object using FTBAnimationController(displayType:direction:speed:) for push and pop.
  // 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
       }

   }

  }

Tab Bar

  • Assign the delegate property of the tab bar controller to one of the root view controllers of the tab bar controller.
  • Add an extension to a root view controller that includes the UITabBarControllerDelegate and necessary transitioning method.
  • Return an instance of the FTBAnimationController animator object using FTBAnimationController(displayType:direction:speed:).
  // 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)

      }

  }

Known Issues

  • Drawing/Rendering images in the animator object is problematic for the simulator, especially iPhone 7/7P. Device testing is recommended.
  • drawHierarchy(in:afterScreenUpdates:) is used for modal presentations and may cause an inconspicuous flicker.

License

  • FlipTheBlinds is released under the MIT license. See LICENSE for details.