Search code examples
ioscocoatouchcgaffinetransform

Cocoa Touch, set transform identity equal to current transform state


How do I change the transformIdentity. How do we set the transform "zero", or alter the transformIdentity of a view to the current state of the transform of said view.

In other words, I want to scale a view, and then set the current state (say scale of 2.5) to the default scale of the view (scale of 1).

example code:

   view.transform = CGAffineTransformMakeScale(1, 2.5);

pseudo code for what I want to do:

   view.transform = setTransformIdentityTo:view.currentState;

If I understand correctly transformIdentity is the state at which a scale would be 1, or a rotation would be zero, the default "zero" transform.

NOTE: The reason I want to do this is so that I can set a negative scale transform on only one axis of the view and alway get a flipped view relative to the last state of the view before the flip was invoked.


Solution

  • CGAffineTransformIdentity does reset a view or layer to its original, untransformed state, and thus cannot be redefined.
    But if you want your "personal" reset transform, e.g. with a different scale, why don't you simply define it, e.g. by using CGAffineTransform myCGAffineTransformIdentity = CGAffineTransform CGAffineTransformMakeScale (sx,sy);, and apply it to your views?