Skip to content

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

License

Notifications You must be signed in to change notification settings

truffls/view-transformers-ios

Repository files navigation

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!

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published