View2ViewTransition

Custom interactive view controller transition from one view to another view.

  • Owner: naru-jpn/View2ViewTransition
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

View2ViewTransition

Carthage compatible Pod Version Swift Version License MIT Plaforms

Simple framework for custom interactive viewController transition from one view to another view.

Installation

Carthage

github "naru-jpn/View2ViewTransition"

CocoaPods

pod 'View2ViewTransition'

Usage

Create TransitionController and implement presentation

// Create TransitionController
var transitionController: TransitionController = TransitionController()
// Present view controller with transition delegate
let presentedViewController: PresentedViewController = PresentedViewController()
presentedViewController.transitioningDelegate = transitionController

transitionController.present(viewController: presentedViewController, on: self, attached: presentedViewController, completion: nil)

(also supports push)

// Set transitionController as a navigation controller delegate and push.
let presentedViewController: PresentedViewController = PresentedViewController()

if let navigationController = self.navigationController {
   navigationController.delegate = transitionController
   transitionController.push(viewController: presentedViewController, on: self, attached: presentedViewController)
}

Presenting viewController conforms View2ViewTransitionPresenting

func initialFrame(userInfo: [String: AnyObject]?, isPresenting: Bool) -> CGRect
func initialView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> UIView
func prepereInitialView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> Void // (optional)

Presented viewController conforms View2ViewTransitionPresented

func destinationFrame(userInfo: [String: AnyObject]?, isPresenting: Bool) -> CGRect
func destinationView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> UIView
func prepareDestinationView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> Void // (optional)

Use UserInfo

You can set userInfo to notify indexPath or share resource etc.

transitionController.userInfo = ["key": "value", ...]

Modify Animation Parameters

Animate with custom animation parameters.

// For present
transitionController.presentAnimationController.usingSpringWithDamping = 0.7
transitionController.presentAnimationController.initialSpringVelocity = 0.0
transitionController.presentAnimationController.animationOptions = [.CurveEaseInOut]

// For dismiss
transitionController.dismissAnimationController.usingSpringWithDamping = 0.7
transitionController.dismissAnimationController.initialSpringVelocity = 0.0
transitionController.dismissAnimationController.animationOptions = [.CurveEaseInOut]

Debug Mode

If you have hierarchical view controllers (navigation controllers) in app, viewController to conform protocol is not intuitive. View2ViewTransition prints some information in debug mode.

let transitionController = TransitionController()
// ...
transitionController.debuging = true

Example

View2ViewTransitionExample

Main metrics

Overview
Name With Ownernaru-jpn/View2ViewTransition
Primary LanguageSwift
Program languageSwift (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2016-08-29 05:02:27
Pushed At2018-12-23 09:38:28
Last Commit At2018-12-05 15:26:26
Release Count13
Last Release Name1.2.0 (Posted on )
First Release Name0.0.1 (Posted on 2016-08-29 14:50:13)
用户参与
Stargazers Count850
Watchers Count14
Fork Count54
Commits Count87
Has Issues Enabled
Issues Count22
Issue Open Count0
Pull Requests Count14
Pull Requests Open Count0
Pull Requests Close Count4
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private