Spring README

The project's README from github.com/MengTo/Spring. As one markdown file: README.md.

Updated for Swift 4.2

Requires Xcode 10 and Swift 4.2.

Installation

Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups").

Or via CocoaPods:

use_frameworks!
pod 'Spring', :git => 'https://github.com/MengTo/Spring.git'

Usage with Storyboard

In Identity Inspector, connect the UIView to SpringView Class and set the animation properties in Attribute Inspector.

Usage with Code

layer.animation = "squeezeDown"
layer.animate()

Demo The Animations

Chaining Animations

layer.y = -50
animateToNext {
  layer.animation = "fall"
  layer.animateTo()
}

Functions

animate()
animateNext { ... }
animateTo()
animateToNext { ... }

Animation

shake
pop
morph
squeeze
wobble
swing
flipX
flipY
fall
squeezeLeft
squeezeRight
squeezeDown
squeezeUp
slideLeft
slideRight
slideDown
slideUp
fadeIn
fadeOut
fadeInLeft
fadeInRight
fadeInDown
fadeInUp
zoomIn
zoomOut
flash

Curve

spring
linear
easeIn
easeOut
easeInOut

Properties

force
duration
delay
damping
velocity
repeatCount
scale
x
y
rotate

* Not all properties work together. Play with the demo app.

Autostart

Allows you to animate without code. Don't need to use this if you plan to start the animation in code.

Autohide

Saves you the hassle of adding a line "layer.alpha = 0" in viewDidLoad().

Known issue

Animations won't autostart when view is reached via performSegueWithIdentifier.

Tutorials

ChangeLog

License

Spring is released under the MIT license. See LICENSE for details.

Spring (MengTo/Spring)

Searching Database…

14.1K ·GitHub
What is this?Spring is a Swift library for iOS that adds ready-made view animations (shake, pop, swing, flip, slide, fade, zoom and more) you can trigger from code or wire up directly in Storyboard.
Is it a framework or just a UIView helper?It is a lightweight library, not a full framework: it extends UIView with animation properties and functions you call in code, plus a SpringView class you can attach directly in Storyboard.
How do I add it to my Xcode project?Drag the Spring folder into your Xcode project (enabling 'Copy items if needed' and 'Create groups'), or install it via CocoaPods.
Does it need a specific Xcode or Swift version?Yes, this version of Spring requires Xcode 10 and Swift 4.2.
Any known gotchas with the animations?Animations won't autostart when the view is reached via performSegueWithIdentifier, and not all animation properties (force, duration, damping, velocity, etc.) work together — the README suggests testing combinations in the demo app.
Can I trigger an animation without writing any code?Yes, there is an Autostart option that plays the animation automatically, and an Autohide option that saves you from manually setting layer.alpha = 0 in viewDidLoad().
Can I chain multiple animations together?Yes, using animateToNext you can run one animation and then kick off another once it finishes, e.g. moving a view and then making it fall.
What animation curves can I use?Spring supports spring, linear, easeIn, easeOut, and easeInOut curves for its animations.
Can I use Spring in an Objective-C project?Yes, the README links to a separate tutorial specifically for integrating Spring into existing Objective-C projects.
Creator
MengTo
Size
0.9 MB
Stars
14.1K
Updated
CommitAug 14
Age
11y
Commits · 90 Days