Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 652
Allyn Avatar asked Dec 14 '10 22:12

Allyn


1 Answers

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

like image 77
jlalvarez18 Avatar answered Nov 12 '22 17:11

jlalvarez18