Skip to content

Guide · Open source

How to use Spring: iOS animations in Swift, step by step

Updated · written with AI from the project's own documentation and checked against our catalogue data

Spring is an MIT-licensed Swift library for iOS that provides prebuilt animations such as shake, pop, fade, slide and zoom, which you can apply to UI views. This guide shows you how to add it to an Xcode project, set animations in Storyboard or in code, and chain them together. It also explains where the project's own README says it stops working well.

SpringMengTo/Spring · ★ 14.1k · MIT

Quick start

  1. 1Check your environment. Confirm you have Xcode 10 and Swift 4.2, since the README says the library was updated for these.
  2. 2Add Spring to your project. Clone the repository and drop the Spring folder into Xcode, enabling Copy items if needed and Create groups. Or add the CocoaPods entry to your Podfile.
  3. 3Set the view class. In Storyboard, open the Identity Inspector and set the UIView's class to SpringView.
  4. 4Pick an animation. In the Attribute Inspector, choose an animation and curve, such as squeezeDown with spring.
  5. 5Trigger it. Either enable Autostart, or in code set layer.animation and call layer.animate().
  6. 6Chain animations. Use animateToNext with a closure to run a second animation after the first, as in the README example.
  7. 7Test combinations. Because not all properties work together, try your settings in the demo app or on your own screen before shipping.

What Spring does and who it suits

Spring gives you a set of ready-made animations for user interface views, so you do not have to write animation math by hand. It is aimed at iOS developers who want common UI motion quickly, and at developers who prefer setting animations in Storyboard with little code.

The README states it was updated for Swift 4.2 and requires Xcode 10 and Swift 4.2, so it fits best with older iOS projects of that era.

  • Good fit: iOS projects built on Swift 4.2 and Xcode 10, quick prototypes, Storyboard-based interfaces.
  • Poor fit: current Swift or Xcode versions, Android or web projects, and teams that need a documented, versioned API.

What you need before installing

The README lists Xcode 10 and Swift 4.2 as requirements. CocoaPods is optional and only needed if you use the pod install route. The project is iOS-only.

  • Xcode 10
  • Swift 4.2
  • CocoaPods (optional)

Install Spring with the folder or CocoaPods

The simplest route is to clone the repository and drop the Spring folder into your Xcode project. When adding it, enable "Copy items if needed" and "Create groups".

If you use CocoaPods, add the Spring entry to your Podfile, including use_frameworks!, and then install as usual.

  • Clone the repository and copy the Spring folder into your project.
  • Enable "Copy items if needed" and "Create groups" when adding it.
  • Or add the CocoaPods entry shown below to your Podfile.
git clone https://github.com/MengTo/Spring use_frameworks! pod 'Spring', :git => 'https://github.com/MengTo/Spring.git'

Animate a view in Storyboard

In Storyboard, select the view, open the Identity Inspector and set its class to SpringView. Then set the animation properties in the Attribute Inspector. Autostart lets the animation run without code, and Autohide saves you from setting layer.alpha = 0 in viewDidLoad().

  • Connect the UIView to the SpringView class in the Identity Inspector.
  • Set the animation properties in the Attribute Inspector.
  • Use Autostart if you do not want to start the animation in code.

Animate a view in code

To animate in code, set the animation name on the view's layer and call animate(). The README's example uses squeezeDown. You can also chain animations: set a starting position, then call animateToNext with a closure that sets the next animation and calls animateTo().

  • Functions in the README: animate(), animateNext { ... }, animateTo(), animateToNext { ... }.
  • Properties include force, duration, delay, damping, velocity, repeatCount, scale, x, y and rotate.
  • Not all properties work together, so test combinations in the demo app.
layer.animation = "squeezeDown" layer.animate() layer.y = -50 animateToNext { layer.animation = "fall" layer.animateTo() }

Choose animations and curves

Spring includes named animations such as shake, pop, morph, wobble, swing, flipX, flipY, fall, squeeze variants, slide variants, fade variants, zoomIn, zoomOut and flash. Curves include spring, linear, easeIn, easeOut and easeInOut. The README links to a demo screen that shows the animations.

  • Animation examples: shake, pop, fadeIn, slideUp, zoomIn, flash.
  • Curve examples: spring, linear, easeIn, easeOut, easeInOut.

Known limits and where to get help

The README records one known issue: animations won't autostart when a view is reached via performSegueWithIdentifier. Tutorials are linked from Design+Code, and the project's changelog lives on its GitHub wiki. The README is short and no release is published, so check the repository's current state before relying on it.

  • Known issue: Autostart does not work when the view is reached via performSegueWithIdentifier.
  • Tutorials: Design+Code (designcode.io/swiftapp).
  • Changelog: the CHANGELOG page on the GitHub wiki.

What people use it for

  • Adding a shake to a form field to signal an input error.
  • Making a card pop or fade in when a screen appears.
  • Sliding a menu panel up or down with a Storyboard setting.
  • Prototyping screen transitions quickly before writing custom animation code.
  • Maintaining an existing Swift 4.2-era iOS app that already uses Storyboard.

Frequently asked questions

Is Spring free to use?

Yes. Spring is released under the MIT license, as stated in the README's License section. See the LICENSE file in the repository for the full terms.

How do I install Spring?

The README gives two routes: clone the repository and drop the Spring folder into your Xcode project, or add pod 'Spring' with a git source to your Podfile using use_frameworks!. Enable Copy items if needed and Create groups when adding the folder.

What versions of Xcode and Swift does Spring need?

The README says it requires Xcode 10 and Swift 4.2 and was updated for those versions. It may not work with current Swift or Xcode releases, so check compatibility before using it in a new project.

Can I use Spring for Android or web apps?

No. Spring is an iOS library written in Swift, so it is not suitable for Android or web animations. For those platforms you would need a different tool.

Does Spring work without writing code?

Yes, you can connect a view to SpringView in Storyboard and set animation properties in the Attribute Inspector. Autostart lets the animation run without code, though the README notes a known issue with performSegueWithIdentifier.

What are alternatives to Spring?

The source lists Lottie, Hero, SwiftEntryKit and Shimmer as comparable projects. The source does not compare them in detail, so review each one's documentation for your use case.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Spring suits iOS developers working on Swift 4.2-era projects who want common UI animations with little code, especially from Storyboard. Skip it if you need current Swift or Xcode support, Android or web animations, or a documented, versioned API, since the README is short and no release is published.

Install options & downloads