Latest 1.0.0
Homepage https://github.com/pietrorea/SpringAnimationController
License MIT
Platforms ios 10.0
Authors

Version
License
Platform

SpringAnimationController provides a subtle way to spice up the default modal presentation style on iOS using spring animations. Simply implement the UIViewControllerTransitioningDelegate protocol and return this animation controller to add some bounce at the top of your modal presentation.

Demo

Usage

First, set up the view controller that you want to present modally and trigger the model presentation as you normally would.

let viewControllerToPresent = PresentedViewController()
viewControllerToPresent.transitioningDelegate = self
viewControllerToPresent.modalPresentationStyle = .custom

present(viewControllerToPresent, animated: true)

Next, implement UIViewControllerTransitioningDelegate to return an instance of SpringyAnimationController

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

    let bouncyTransition = SpringAnimationController(isPresenting: true)
    return bouncyTransition
}

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

    let bouncyTransition = SpringAnimationController(isPresenting: false)
    return bouncyTransition
}

You can also customize the animation duration, spring damping and spring velocity before returning the animation controller.

let bouncyTransition = SpringAnimationController(isPresenting: true)
bouncyTransition.transitionDuration = 0.35
bouncyTransition.springDamping = 0.5
bouncyTransition.springVelocity = 0.7

Example

To run the example project, simply run pod try SpringAnimationController .

Requirements

iOS 10 and above

Installation Instructions

SpringAnimationController is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SpringAnimationController'

License

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

Latest podspec

{
    "name": "SpringAnimationController",
    "version": "1.0.0",
    "summary": "A custom modal UIViewController presentation that mimics a spring.",
    "description": "SpringAnimationController provides a suble way to spice up the default modal presentantion style on iOS. Simply set the UIViewControllerTransitioningDelegate and return this animation controller to add some bounce at the top of your modal presentation.",
    "homepage": "https://github.com/pietrorea/SpringAnimationController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "pietrorea": "[email protected]"
    },
    "social_media_url": "https://twitter.com/pietrorea",
    "source": {
        "git": "https://github.com/pietrorea/SpringAnimationController.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.1",
    "source_files": "SpringAnimationController/Classes/*.swift"
}

Pin It on Pinterest

Share This