Search code examples
ioscgaffinetransform

How to get CGAffineTransform from two CGSizes?


Suppose, I have two CGSize named A and B.

Where

B = CGSizeApplyAffineTransform(A, CGAffineTransformMakeScale(x,y));

Now how to calculate x and y if I know A and B?


Solution

  • The scale factor for transforming one size to another is simply dividing the target dimension with the current dimension. That means x=B.width/A.width same for height.

    Though it is not clear from the question if this is what you wanted, so the solution might as well be x=y=42.