I’m wondering if it possible to actually change a UIViews scale value without actually scaling it? For instance, how do you change this transform.scale value:
[[[[myView] layer] valueForKeyPath:@"transform.scale"] floatValue];
My reason for doing this is pretty ocdish. I have an application where I import an image that the user can drag around the screen and scale. When the image is imported, I initially have to scale it and center it to fit within the view. When I scale it, it’s “transform.scale” value changes from 1 to whatever I scale it too. There is a work around this if I do the scaling by setting the frame instead of doing CGAffineTransformScale. However, I’d like to avoid that and would simply just like to reset the scale value to 1 somehow.
You can’t reset
the scale to 1 once you have scaled it, however you could have aninitialScalevariable and store this initial scale. When the user starts to scale after that, simply apply the scale factor to thisinitialScale` to get the actual scale.So for example, you scale the image initially to fit and it has a scale of 0.8 set
initialScaleto 0.8.When the user starts to scale the image down from 1 to 0.5 for instance, apply this change to your initial scale, so user scales to 0.5, multiply the initial scale by this which equals 0.4.