I would like to apply multiple transforms to a
You can apply multiple transforms by stacking them on top of each other.
var t = CGAffineTransformIdentity t = CGAffineTransformTranslate(t, CGFloat(100), CGFloat(300)) t = CGAffineTransformRotate(t, CGFloat(M_PI_4)) t = CGAffineTransformScale(t, CGFloat(-1), CGFloat(2)) // ... add as many as you want, then apply it to to the view imageView.transform = t
This series of transforms produces the image on the right:
Thanks to this answer for teaching me how to do it.
The order in which you apply the transforms matters.
The CGAffineTransforms with
Make in their name create transformation matrices. You would use these if you only wanted to do a single transform or if you wanted to start a series of transforms with one of them. (In the example above we used
CGAffineTransformIdentity to create our initial matrix.)
The following, which we used in our example, are used to add an additional transform to an existing matrix.