Skip to content

A library used to create beautiful animations and transitions for iOS.

License

Notifications You must be signed in to change notification settings

CosmicMind/Motion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motion Logo

Motion

Welcome to Motion, a library used to create beautiful animations and transitions for views, layers, and view controllers.

Photos Sample

Take a look at a sample Photos project to get started.

Photos

Who is Motion for?

Motion is designed for beginner to expert developers. For beginners, you will be exposed to very powerful APIs that would take time and experience to develop on your own, and experts will appreciate the time saved by using Motion.

What you will learn

You will learn how to use Motion with a general introduction to fundamental concepts and easy to use code snippets.

Transitions

Motion transitions a source view to a destination view using a linking identifier property named motionIdentifier.

Match Translate Rotate Arc Scale
Match Translate Rotate Arc Scale

Example Usage

An example of transitioning from one view controller to another with transitions:

View Controller 1

greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"

View Controller 2

isMotionEnabled = true
greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"
orangeView.transition(.translate(x: -100))

The above code snippet tells the source views in view controller 1 to link to the destination views in view controller 2 using the motionIdentifier. Animations may be added to views during a transition using the transition method. The transition method accepts MotionTransition structs that configure the view's animation.

UINavigationController, UITabBarController, and UIViewController Transitions

Motion offers default transitions that may be used by UINavigationControllers, UITabBarControllers, and presenting UIViewControllers.

Push Slide ZoomSlide Cover Page Fade Zoom
Push Slide Zoom Slide Cover Page Fade Zoom

Example Usage

An example of transitioning from one view controller to another using a UINavigationController with a zoom transition:

UINavigationController

class AppNavigationController: UINavigationController {
    open override func viewDidLoad() {
        super.viewDidLoad()
        isMotionEnabled = true
        motionNavigationTransitionType = .zoom
    }
}

To add an automatic reverse transition, use autoReverse.

motionNavigationTransitionType = .autoReverse(presenting: .zoom)

Animations

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 Corner Radius Fade Rotate Size Spring
Background Color Corner Radius Fade Rotate Size Spring
Border Color & Border Width Depth Position Scale Spin Translate
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.

Requirements

  • iOS 8.0+
  • Xcode 8.0+

Communication

  • If you need help, use Stack Overflow. (Tag 'cosmicmind')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, and can provide steps to reliably reproduce it, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Embedded frameworks require a minimum deployment target of iOS 8.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Motion's core features into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Motion', '~> 3.1.0'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Motion into your Xcode project using Carthage, specify it in your Cartfile:

github "CosmicMind/Motion"

Run carthage update to build the framework and drag the built Motion.framework into your Xcode project.

Change Log

Motion is a growing project and will encounter changes throughout its development. It is recommended that the Change Log be reviewed prior to updating versions.

License

The MIT License (MIT)

Copyright (C) 2019, CosmicMind, Inc. http://cosmicmind.com. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.