Home

Awesome

Disintegrate

CI Status Version Carthage compatible License Platform

Disintegrate is a small library providing an animation inspired by how our favorite heroes disappeared at the end of Avengers: Infinity War. The view or layer that you use it on is divided into small triangles, which then move into one direction and fade away. You can customize the estimated number of triangles and the direction they will move to.

<div align="center"> <div> <img src="Assets/disintegrationDemoLabel.gif" width="25%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="Assets/disintegrationDemo.gif" width="25%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="Assets/disintegrationDemoBigImage.gif" width="25%"> </div> </div> <br>

Usage

Disintegrate adds a single method to both UIView and CALayer classes.

func disintegrate(direction: DisintegrationDirection = DisintegrationDirection.random(),
                  estimatedTrianglesCount: Int = 66,
                  completion: (() -> ())? = nil)

The animation can be customized by two parameters:

Additionally, you can specify a completion block that will be executed when the animation finishes.

Here are some examples of using Disintegrate:

avatarImageView.disintegrate()
cancelButton.disintegrate(direction: .upperLeft)
gradientLayer.disintegrate(estimatedTrianglesCount: 100)
errorLabel.disintegrate(direction: .down, estimatedTrianglesCount: 200) {
    print("Error label animation finished.")
}

Installation

CocoaPods

Disintegrate is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Disintegrate'

Carthage

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

github "dbukowski/Disintegrate" ~> 0.2.0

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

Manually

Alternatively, you can simply copy the 3 files from Disintegrate/Classes directory.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Disintegrate requires iOS 8.0 or later.

Author

Maintained by Maciej Mastalerz, maciej.mastalerz@gmail.com

Created by Dariusz Bukowski, dariusz.m.bukowski@gmail.com

License

Disintegrate is available under the MIT license. See the LICENSE file for more info.