Giter Site home page Giter Site logo

mohsinalimat / fliptheblinds Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joelconnects/fliptheblinds

1.0 3.0 0.0 13.58 MB

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

License: MIT License

Ruby 1.13% Swift 98.87%

fliptheblinds's Introduction

Platform Language Swift 3.0 License

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

Animated GIF

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.

fliptheblinds's People

Contributors

joelconnects avatar

Stargazers

MohsinAli avatar

Watchers

James Cloos avatar MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.