Search code examples
iphonemathscalecatransform3d

Getting the 'scale' from a CATransform3D


I am creating an iPad app and want to update the user with the current size of a view. I used to be doing this by calculating the scale of a CGAffineTransform and multiplying the xScale by the width (of the related view) and the yScale by the height. I'd like to keep doing this, but I'm no longer doing 2d transformations, and I'm not sure what equation to use to extract the scale information from CATransform3D.

Can you help?


Solution

  • To get the current scale of the layer you just perform a valueForKeyPath: on the layer:

    CGFloat currentScale = [[layer valueForKeyPath: @"transform.scale"] floatValue];
    

    Other keys can be found in Apples Core Animation Programming Guide