On iOS, after creating a layer from a context and getting a layer context, how do these contexts relate to each other?

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?

+3
source share
1 answer

, CGLayer. CGLayer , .

(: - , 32- RGBA PDF ..)

CGLayer, , CGLayer . CGLayer .

, CGLayer , , .

CGLayer , - , . , , , .

CGLayerCreateWithContext :

, . .

, context. , context CGLayer . , - .

CGLayerGetContext

- , , .

, , context != contextOfLayer.

, API , - , . API .

:

contextOfLayer ?

, . API - , .

, contextOfLayer , , " " ?

, . " " UIKit . CGLayer CoreGraphics - API , UIKit.

+3

All Articles