views:

103

answers:

1

Hey I'm trying to do the equivalent thing that the iOS 4.0 method CALayer::contentsScale does, which scales the size of the backing bitmap of the layer. Any way to do this in iOS 3.2, probably by setting the frame size and applying a transform?

+3  A: 

You can scale a layer in all iOS versions by applying a scaling affine transform to the layer, e.g.:

CGAffineTransform scaleTransform = CGAffineTransformMakeScale(2.0, 2.0);
[myLayer setAffineTransform:scaleTransform];

I'm not familiar with the subtleties of behavior of the layer's contentsScale property-- this is probably not a drop-in replacement for it, but depending on what your use case is, might accomplish what you want just fine.

If you're just doing a scale, then the position of the layer should be the same as the anchorPoint, and you'll scale about the center, which is probably what you want. If you want to do anything more complex, be sure to understand what the anchor point is. (Docs here)

quixoto