Animate
class Animate
            Class for creating animations. Chains together animation ‘sentences’ using self-returning functions and completion handlers.
Animate(view, duration).setOptions(.curveLinear).rotate(to: 90)
          let view = Animate(view, duration)
view.setSpring(damping, velocity).translate(by: [50, 0], then: {
    view.flip().shake(then: {
       view.reset()
    })
})
          
        - 
                
                
Undocumented
Declaration
Swift
typealias Completion = () -> () 
- 
                
                
Undocumented
Declaration
Swift
private var duration: Double - 
                
                
Undocumented
Declaration
Swift
var originalDuration: Double - 
                
                
Undocumented
Declaration
Swift
private var origin: Array<CGFloat> - 
                
                
Undocumented
Declaration
Swift
init(_ view: UIView, _ duration: Double? = nil) 
- 
                
                
Set the options for all animations.
See
UIView.animate(options: UIViewAnimationOptions)for more information.Declaration
Swift
@discardableResult func setOptions(_ options: UIViewAnimationOptions) -> Animate - 
                
                
Set the spring damping and velocity for all animations.
See
UIView.animate(usingSpringWithDamping:)andUIView.animate(initialSpringVelocity:)for more information.Declaration
Swift
@discardableResult func setSpring(_ damping: CGFloat, _ velocity: CGFloat) -> Animate - 
                
                
Set the delay for all animations.
Declaration
Swift
@discardableResult func setDelay(_ delay: Double) -> Animate - 
                
                
Set the duration for all animations.
Declaration
Swift
@discardableResult func setDuration(_ duration: Double) -> Animate - 
                
                
Convenience function that sets animation durations to
0(instant).Declaration
Swift
@discardableResult func now() -> Animate - 
                
                
Convenience function that sets animation durations to back to the last set duration.
Declaration
Swift
@discardableResult func notnow() -> Animate - 
                
                
Cancel current animations on the view layer. The transform does not reset.
Declaration
Swift
@discardableResult func cancel(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Chainable wait function.
Declaration
Swift
@discardableResult func wait(asec: Double, then: Completion?) -> AnimateParameters
asecTime in seconds to wait.
thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Tilt animation. Tilt in one direction, then tilt back to origin.
Declaration
Swift
@discardableResult func tilt(degrees: Double, then: Completion? = nil) -> AnimateParameters
degreesAmount to tilt. Positive or negative determines direction.
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Shaking animation.
Important
Uses
Animate().translate, so be aware if applying this animation along with anAnimate().rotatetransform.Declaration
Swift
@discardableResult func shake(vertical: Bool? = nil, keys: Array<Double>? = nil, then: Completion? = nil) -> AnimateParameters
verticalIf
true, the animation will be a vertical shake, else it will be a horizontal shake. Defaultfalse.- keys: An array describing points to move to along a single axis in reference to the origin.
                                      Passing
                                      
nilto this parameter will use the default[10, -10, 7, -7, 4, -4, 1, -1]. - then: Nullable completion handler, executed after the duration of the animation.
 
 - keys: An array describing points to move to along a single axis in reference to the origin.
                                      Passing
                                      
 - 
                
                
Jiggle animation.
Declaration
Swift
@discardableResult func jiggle(_ amount: Double = 1.08, _ times: Int = 7, then: Completion? = nil) -> AnimateParameters
amountThe maximum size to which the view can be jiggled. Default
1.08.timesThe number of times the view should jiggle. Default
7.thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Declaration
Swift
@discardableResult func fadeIn(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Shrink and fade the view to a scale that’s near invisible.
Declaration
Swift
@discardableResult func shrinkAndWink(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Set the view to a scale and opacity that’s near invisible, then grow to full size.
Declaration
Swift
@discardableResult func growAndShow(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Flashing
not compatible with .now() since it’s a repeating animation
Declaration
Swift
@discardableResult func flashing(_ on: Bool) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Change the view layer opacity to a percentage.
Declaration
Swift
@discardableResult func fade(to: Float, then: Completion? = nil) -> AnimateParameters
toFade the view layer opacity to this percentage.
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Change the view layer opacity by a percentage. (e.g. If the current opacity is 0.5,
.fade(by:0.5)will change the opacity to0.25or0.5 * 0.5)Important
Requires the view opacity to be
> 0.Declaration
Swift
@discardableResult func fade(by: Float, then: Completion? = nil) -> AnimateParameters
byFade the view layer opacity by this percentage.
thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
2D Flip animation.
Declaration
Swift
@discardableResult func flip(vertical: Bool? = nil, then: Completion? = nil) -> AnimateParameters
verticalIf
true, the animation will be a vertical flip, else it will be a horizontal flip. Defaultfalse.thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Move the view origin to point [x, y] in the superviews space.
This animation is different from
.translate(to:). It moves the origin of the view frame.Declaration
Swift
@discardableResult func move(to: Array<CGFloat>, then: Completion? = nil) -> AnimateParameters
toAn array consisting of two
CGFloat, ordered as[x, y]. This is the point to which the origin is moved. This functions differently from.translate(to:).thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Move the view origin by this amount [x, y] in relation to the current view origin.
This animation is different from
.translate(by:). It moves the origin of the view frame.Declaration
Swift
@discardableResult func move(by: Array<CGFloat>, then: Completion? = nil) -> AnimateParameters
byAn array consisting of two
CGFloat, ordered as[x, y]. This is the amount by which the origin is moved.thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Move the view center to point [x, y] in the superviews space.
This animation is different from
.translate(to:). It moves the center of the view frame.Declaration
Swift
@discardableResult func move(center to: Array<CGFloat>, then: Completion? = nil) -> AnimateParameters
toAn array consisting of two
CGFloat, ordered as[x, y]. This is the point to which the center is moved. This functions differently from.translate(to:).thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Translate the view layer to point [x, y] in relation to the layer origin.
This will reset all other transforms on the layer.
This animation is different from
.move(to:). It is a transform on the view layer and does not change the actual frame location.Important
.translatedoes not work as you might expect when combined with.rotatetransform. Use.move(by:)if you need to chain animations that move and rotate.Declaration
Swift
@discardableResult func translate(to: Array<CGFloat>, then: Completion? = nil) -> AnimateParameters
toAn array consisting of two
CGFloat, ordered as[x, y]. This represents a point in relation to the view layers origin to which the layer is translated. This functions differently from.move(to:).thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Translate the view layer by [x, y] amount in relation to the layers current position.
This animation is different from
.move(by:). It is a transform on the view layer and does not change the actual frame location.Important
.translatedoes not work as you might expect when combined with.rotatetransform. Use.move(by:)if you need to chain animations that move and rotate.Declaration
Swift
@discardableResult func translate(by: Array<CGFloat>, then: Completion? = nil) -> AnimateParameters
byAn array consisting of two
CGFloat, ordered as[x, y]. This represents a point in relation to the view layers origin to which the layer is translated.thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Uniformly scale the view layer to an amount in relation to its original size.
Using this animation will reset any other transforms.
Important
.scale(to:)values are in relation to the original scale..scale(to: 1.5)would scale a view to 150% its original size, and.scale(to: 1)would then scale it back to it’s original size.Declaration
Swift
@discardableResult func scale(to: CGFloat, then: Completion? = nil) -> AnimateParameters
toAmount to which the view layer is scaled.
1.0will always be the original size.thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Uniformly scale the view layer by an amount in relation to its current transform.
Important
.scale(by:)values are in relation to the current scale, which is always represented as1.0. If you scale to1.5, then try to scale to1.0there would be no change. To more easily calculate values for.scale(by:), you could use fractions instead of decimals. Scale to3/2to increase size by 50%, then scale to2/3to get back to the original size.Declaration
Swift
@discardableResult func scale(by: CGFloat, then: Completion? = nil) -> AnimateParameters
byAmount by which the view layer is scaled.
1.0will always be no change.thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Rotate the view layer around its center point, to an angle in degrees in relation to its origin.
Using this animation will reset any other transforms.
Important
.translatedoes not work as you might expect when combined with.rotatetransform. Use.move(by:)if you need to chain animations that move and rotate.Declaration
Swift
@discardableResult func rotate(to: Double, then: Completion? = nil) -> AnimateParameters
toRotate the view layer to this angle in degrees. Positive or negative determines direction.
thenNullable completion handler, executed after the duration of the animation.
 - 
                
                
Rotate the view layer around its center point, by an amount in degrees in relation to its current transform.
Important
.translatedoes not work as you might expect when combined with.rotatetransform. Use.move(by:)if you need to chain animations that move and rotate.Declaration
Swift
@discardableResult func rotate(by: Double, then: Completion? = nil) -> AnimateParameters
byRotate the view layer by this amount in degrees. Positive or negative determines direction.
thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Invert the view layers current transform. No change if the transform is already its identity.
Declaration
Swift
@discardableResult func invert(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 
- 
                
                
Animates the view layer and frame back to its original state.
Declaration
Swift
@discardableResult func reset(then: Completion? = nil) -> AnimateParameters
thenNullable completion handler, executed after the duration of the animation.
 
 Animate Class Reference