Latest 0.0.1
Homepage https://github.com/lkzhao/Elastic
License MIT
Platforms ios 9.0, requires ARC
Dependencies Hero
Authors

Carthage compatible
Version
License
Xcode 8.2+
iOS 8.0+
Swift 3.0+

Fancy elastic transition powered by Metal, UIKit Dynamics, & Hero:

Elastic

Just a proof of concept inspired by Álvaro Carreras’s Slide Concept. Not really optimized and does not support older devices. You should not use this in production. If you want something similar, checkout ElasticTransition

Supports UINavigationController, UITabBarController, & Modal Present. Since it is powered by Hero, the other views can still benefit from animations constructed by Hero.

Requirements

  • Xcode 8.2
  • Swift 3.0.2
  • Metal compatible devices (iPhone 5s or newer)

Won’t work on simulator.

Installation

pod "Elastic"

Usage

  override func viewDidLoad() {
    super.viewDidLoad()
    // 1. Enable the plugin
    ElasticHeroPlugin.isEnabled = true

    // 2. setup a gesture recognizer
    let leftGR = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(pan(gr:)))
    leftGR.edges = UIRectEdge.left
    view.addGestureRecognizer(leftGR)

    // 3. set the heroModifier of the elastic view to be
    view.heroModifiers = [.elastic(edge: .left, gestureRecognizer: leftGR)]
  }

  func pan(gr:UIScreenEdgePanGestureRecognizer){
    if gr.state == .began {
      // 4. perform your transition when the gesture recognizer begans. the rest will be handled automatically
      performSegue(withIdentifier: "next", sender: nil)
    }
  }

The elastic view doesn’t have to be the gesture recognizer’s view. For example, the following code makes the next view controller’s view elastic.

  // This replaces step 3
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let vc = segue.destination
    vc.view.heroModifiers = [.elastic(edge: .right, gestureRecognizer: rightGR)]
  }

License

Elastic is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Elastic",
    "version": "0.0.1",
    "summary": "Fancy elastic transition powered by Metal, UIKit Dynamics, & Hero",
    "description": "Fancy elastic transition powered by Metal, UIKit Dynamics, & Hero. Written in Swift.",
    "homepage": "https://github.com/lkzhao/Elastic",
    "screenshots": "https://github.com/lkzhao/Elastic/blob/master/Resources/elastic.png?raw=true",
    "license": "MIT",
    "authors": {
        "Luke": "[email protected]"
    },
    "source": {
        "git": "https://github.com/lkzhao/Elastic.git",
        "tag": "0.0.1"
    },
    "platforms": {
        "ios": "9.0"
    },
    "ios": {
        "frameworks": [
            "UIKit",
            "Foundation",
            "MetalKit"
        ]
    },
    "requires_arc": true,
    "source_files": "Sources/*.swift",
    "dependencies": {
        "Hero": []
    },
    "pushed_with_swift_version": "3.0.2"
}

Pin It on Pinterest

Share This