We can create a layer from the current graphics context, and then get the layer context:
CGContextRef context = UIGraphicsGetCurrentContext();
CGLayerRef layer = CGLayerCreateWithContext(context,
CGSizeMake(self.frame.size.width,
self.frame.size.height), NULL);
CGContextRef contextOfLayer = CGLayerGetContext(layer);
So, now we have 2 contexts: contextand contextOfLayer. How do these two contexts relate to each other? Is it a contextOfLayerpart contextand contexthas an array of layer context pointers? If I print their addresses with NSLog(@"%p", ...), they have different addresses, so they are not the same object. And I think that contextOfLayerdoes not affect the context stack, so this is just an independent context, just “exists there” in and of itself?
source
share