问题
in -drawRect:
, I created a secondary CGContextRef
using CGBitmapContextCreate()
.
When I'm done with this context, I need to copy it's contents over to the "original" context of -drawRect:. How can I do that?
Reason why I create an additional context: I hope to get CGContextClipToMask() to work in a view that has a transparent background. My idea is to do all the mask-drawing and clipping in another context that has the appropriate color (non-transparent, no alpha), and then somehow paste that result back to the original context.
回答1:
you can use memcpy function. Read on google for how to use it.
回答2:
just use CGBitmapContextCreateImage, and the actual physical copy of the bits occur only if the underlying data in the bitmap graphics context is modified.
来源:https://stackoverflow.com/questions/6315961/how-to-copy-one-cgcontextref-to-another