ViewTransformers lets you pass multiple view transformations as an array to UIView.
Add following to your Podfile
:
use_frameworks!
pod 'ViewTransformers'
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.
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()
})
})
}
Issues and pull requests are welcome!