Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.72 KB

README.md

File metadata and controls

60 lines (43 loc) · 1.72 KB

alt text

Swift Version Platform Compatibility Pod version

ViewTransformers lets you pass multiple view transformations as an array to UIView.

Install via Cocoapods

Add following to your Podfile:

use_frameworks!
pod 'ViewTransformers'

How to use

You can easily pass multiple view transformations to a UIView by using the transforms property on UIView.

view.transforms = [
    CGAffineTransform(scaleX: 0.5, y: 0.5),
    CGAffineTransform(rotationAngle: -1.42),
    CGAffineTransform(translationX: 100, y: -145)
]

Reading the transforms property only returns the merged transformations as one in a one-item-array.

Example

alt text

Used code for the example:

func playAnimation() {
    UIView.animate(withDuration: 1.0, delay: 1.0, options: .curveLinear, animations: {
        self.myView.transforms = [
            CGAffineTransform(scaleX: 0.5, y: 0.5),
            CGAffineTransform(rotationAngle: -1.42),
            CGAffineTransform(translationX: 100, y: -145)
        ]
    }, completion: { _ in
        UIView.animate(withDuration: 1.0, delay: 1.0, options: .curveLinear, animations: {
            self.myView.transforms = nil
        }, completion: { _ in
            self.playAnimation()
        })
    })
}

Contribution

Issues and pull requests are welcome!