简体   繁体   English

如何获得CALayer内部点的绝对位置

[英]How to get absolute position of point inside CALayer

how can I obtain the absolute position of a CGPoint inside a CALayer. 如何获得CGay在CALayer中的绝对位置。 I need this for exact pixel drawing 我需要这个来精确绘制像素

Edit: Absolute to the screen 编辑:绝对到屏幕

Hit test the superlayers recursively, until you arrive at the root layer: 递归地测试超级层,直到您到达根层:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM