Search code examples
iphonecgaffinetransform

How to calculate the rotation and scale from a view's transform property ?


I have a UIView which I rotate to certain angle or say scale to a level and then I stretch it from its two ends. to stretch I need to change its frame. Before Changing the frame I need to restore its transform to identity and then only I can change its frame and apply the same rotation and scale again.


Solution

  • // save it
    CGAffineTransform transform = myView.transform;
    // reset it
    myView.transform = CGAffineTransformIdentity;
    // change the frame
    myView.frame = CGRectMake(/*do stuff to the frame*/);
    // restore it
    myView.transform = transform;