I have a 200x200 pixel
CALayer
instance to which I've applied two transformations:
- scaled down to 50%
- applied a 3D perspective
Now I want to align the transformed layer with another layer. To do that I need the size (width and height) of the transformed layer.
The problem is that layer.bounds
still returns 200x200
for the layer, but because of the perspective transformation the actual visible width is less and the height more than 200
. The bounds of the presentation layer return 0
, by the way.
Is there any way how I can determine the exact size of a transformed CALayer
exactly as it is drawn on screen?
Thanks, Mark.
Finally figured it out: the
bounds
remain unchanged when applying a transformation, but what changes is the layer'sframe
property.Solution is to use
layer.frame.size
instead oflayer.bounds.size
.This is mentioned in the Core Animation Programming Guide: