Motion
  • Introduction
  • Overview
    • Motion
    • Transitions
    • Animations
    • Installation
    • Change Log
  • API
    • MotionTransition
    • MotionAnimation
Powered by GitBook
On this page
  1. Overview

Animations

PreviousTransitionsNextInstallation

Last updated 7 years ago

Motion provides the building blocks necessary to create stunning animations without much effort. Motion's animation API will make maintenance a breeze and changes even easier. To create an animation, use the animate method of a view or layer and pass in a list of MotionAnimation structs. MotionAnimation structs are configurable values that describe how to animate a property or group of properties.

Background Color

Corder Radius

Fade

Rotate

Size

Spring

Border Color & Border Width

Depth

Position

Scale

Spin

Translate

Example Usage

let box = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
box.backgroundColor = .blue

box.animate(.background(color: .red), .rotate(180), .delay(1))

In the above code example, a box view is created with a width of 100, height of 100, and an initial background color of blue. Following the general creation of the view, the Motion animate method is passed MotionAnimation structs that tell the view to animate to a red background color and rotate 180 degrees after a delay of 1 second. That's pretty much the general idea of creating animations.

MotionAnimation API
Code Samples
Fade
Rotate
Spring
Depth
Size
Border Color & Border Width
Corner Radius
Position
Spin
Background Color
Translate
Scale