((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeRotation(1.57*2);
((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeScale(.5,.5);
Just one of these works at a time. How can I save a transformation and then apply another?
Cheers
To expand upon what Peter said, you would want to use code like the following:
CGAffineTransform newTransform;
newTransform = CGAffineTransformMakeRotation(1.57*2);
((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformScale(newTransform,.5,.5);
The CGAffineTransformMake... functions create new transforms from scratch, where the others concatenate transforms. Views and layers can only have one transform applied to them at a time, so this is how you create multiple scaling, rotation, and translation effects on a view at once.
You do need to be careful of the order in which transforms are concatenated in order to achieve the correct effect.
From the Apple Documentation:
CGAffineTransformConcat Returns an
affine transformation matrix
constructed by combining two existing
affine transforms.
CGAffineTransform CGAffineTransformConcat (
CGAffineTransform t1,
CGAffineTransform t2
);
Parameters t1 The first affine
transform.
t2 The second affine transform. This
affine transform is concatenated to
the first affine transform.
Return Value A new affine
transformation matrix. That is, t’ =
t1*t2.
Discussion Concatenation combines two
affine transformation matrices by
multiplying them together. You might
perform several concatenations in
order to create a single affine
transform that contains the cumulative
effects of several transformations.
Note that matrix operations are not
commutative—the order in which you
concatenate matrices is important.
That is, the result of multiplying
matrix t1 by matrix t2 does not
necessarily equal the result of
multiplying matrix t2 by matrix t1.
Just one of these works at a time.
Right, because you replaced the first one with the second.
How can I save a transformation and then apply another?
Concatenate them together, and assign the resulting matrix to the property.
You can store a transformation matrix in a variable of type CGAffineTransform
; you can use that for intermediate steps in more complex transformations, or to make the code clearer (or both).