CGImageCreateWithMask
As the user draws, change CGBitmapContextwith the changes. Keep bound CGImage, which refers to the context. Create a masked image from the original and mask and create from it UIImage.
CGImage, and therefore CGBitmapContextshould be gray. You can use CGImageMaskCreateor CGImageCreateto make the image, but the first is preferable.
, , , UIImage, CGBitmapContext. , , - , , , setNeedsDisplay , UIImage.