Skip to content

A Swift animation DSL for animating layers with help of CoreAnimation

License

Notifications You must be signed in to change notification settings

lotus-ios/lotus

Repository files navigation

Lotus

Language Build Status codecov Version License Platform

Lotus – powerful nano framework that helps implement layer animation with easy syntax. This DSL relieves you from routine code of making animations via CoreAnimation.

Lotus

for i in 0..<10 {
    let petalLayer = PetalLayer()
    petalLayer.position = CGPoint(x: view.frame.width / 2, y: view.frame.height / 2 + 60)

    let direction: CGFloat = i % 2 == 0 ? -1.0 : 1.0
    let initialRotationDegree = 3.0 * CGFloat(i / 2) * .pi / 180.0
    let rotateTransform = CGAffineTransform.identity.rotated(by: direction * initialRotationDegree)
    petalLayer.setAffineTransform(rotateTransform)
    view.layer.addSublayer(petalLayer)

    let rotationDegree = 12.0 * CGFloat(i / 2) * .pi / 180.0
    petalLayer.lotus.runAnimation { make in
        make.opacity.to(0.7).during(0.7).delay(1.0)
    }.then { make in
        make.rotation.to(direction * rotationDegree).during(0.6)
    }.then { make in
        make.scaling.to(1.2).delay(0.3).during(1.5).ease(.outElastic)
    }
}

Contents

Getting started

These instructions will help you to integrate Lotus into your project.

Requirements

  • Xcode 10.2+

Installing

CocoaPods

1. In terminal switch to your repository with project
2. Specify Lotus in your Podfile:

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

target '<Your Target Name>' do
    pod 'Lotus'
end

3. Run pod install command

Usage

1. Import Lotus into your project

import Lotus

2. Create any layer and add to view's hierarchy

let redSquareLayer = CALayer()
redSquareLayer.frame = CGRect(x: 50, y: 50, width: 100, height: 100)
view.layer.addSublayer(redSquareLayer)

3. Then run any needed animation whenever you need

redSquareLayer.lotus.runAnimation { make in
    make.scaling.to(2.0)
}

Documentation

Find out all accessible facilities in Documentation

Contributing

If you found any bug, have great new feature or want to improve documentation – you're welcome! Go to issue page, choose template, write details and we will answer you as soon as possible.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details