如何在CALayer中获得点的绝对位置

时间:2012-03-09 10:34:35

标签: iphone objective-c calayer quartz-graphics

如何在CALayer中获取CGPoint的绝对位置。我需要这个用于精确的像素绘制

编辑:屏幕绝对

1 个答案:

答案 0 :(得分:3)

以递归方式测试超级层,直到到达根层:

CGPoint originalPoint = // wherever from you obtain your original point
CALayer *layer = self;
CGPoint point = originalPoint;
while (layer.superlayer)
{
    point = [layer convertPoint:point toLayer:layer.superlayer];
    layer = layer.superlayer;
}

// here `point' will contain the exact position