I’m working on a project that allows the user to draw anything on an image .. after the user finishes drawing . It closes the path and erase the content of image enclosed in a path and assign a new rectangular frame with a new image that can be dragged, but it only shows the content inside the erased path. Do you have any idea how can i achieve that ? I’m new to swift ios. and i have the code to erase the content of image.
What i need is :
- assign a new image in a resizable rectangular frame
- move the frame to resize accordingly so that it only shows the content inside the erased region This is what I’m trying to do



Assuming you have your enclosed UIBezierPath
Create a CAShapeLayer with the closed path
Create an image layer
Apply the shape layer as a mask to the image layer
Assuming your view is
drawingView