Search code examples
iphoneiosxcodeipadipod

UIImage on CGLayer


I want to draw a simple UIImage on CGLayer, but I cannot find any useful resources to do it. Kindly tell me how to draw UIImage on CGLayer.

Thanks!


Solution

  • Is it this you are looking for ?

    CGContextRef layerCtx = CGLayerGetContext(layer);
     CGContextDrawImage(layerCtx, (CGRect){ CGPointZero, myImage.size }, myImage.CGImage);