简体   繁体   中英

How to get absolute position of point inside CALayer

how can I obtain the absolute position of a CGPoint inside a 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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