gitmyhub

Spring

Swift ★ 14k updated 3y ago

A library to simplify iOS animations in Swift.

A Swift library for iOS that lets you add animations to any view by naming a style and calling one method, no boilerplate, works from Storyboard or pure code.

SwiftCocoaPodsXcodesetup: easycomplexity 2/5

Spring is a Swift library that makes it easier to add animations to iOS apps. Instead of writing a lot of setup code yourself, you assign a named animation style to a view element and call a single method, and the library handles the motion. The library is compatible with Xcode 10 and Swift 4.2.

You can use Spring in two ways. The first is through Storyboard, which is Xcode's visual interface editor: you connect a UIView element to the SpringView class using the Identity Inspector, then set animation properties visually in the Attribute Inspector without writing any code. The second way is to drive animations entirely from code, where you set the animation name and call animate() in just a few lines.

The library ships with a named list of built-in animations, including shake, pop, morph, squeeze, wobble, swing, flipX, flipY, fall, various slide and squeeze directions, fade variants, and zoom and flash effects. Each animation can be adjusted with properties like duration, delay, force, damping, velocity, repeatCount, scale, position offsets, and rotation. You can also chain animations together so that one begins when another finishes, using the animateToNext function.

Two convenience features are included. Autostart lets a view animate as soon as it appears on screen, with no extra code required. Autohide automatically sets a view opacity to zero in viewDidLoad, saving that line of manual setup.

Installation is either by dropping the Spring folder directly into your Xcode project or by listing it as a pod in a CocoaPods Podfile. The README notes that animations will not autostart when a view is reached through performSegueWithIdentifier, which is a known limitation. Tutorial resources link to a Design+Code course. The library is released under the MIT license.

Where it fits