Reversed Mask an UIImage in iOS

Viewed 200

Typically, it will be presented like Figure 3, if use the image masking by below codes,

let maskLayer = CALayer()
maskLayer.contents = [CGImage Object]    // CGImage Object is Figure 2
imageView.layer.mask = maskLayer

But, I want to get the reversed result.
The black area of Figure 2 is clear color.
Yes, I can use reversed image for masking.
Let us assume that the size of Figure 1 is 100x100, Figure 2 is 30x30.
The Result is same with Figure 3.
But, the expected result should present Figure 1 area that outside of Figure 2(masking image), like Figure 4.
How can I do that?

enter image description here

Figure 1

enter image description here

Figure 2

enter image description here

Figure 3

enter image description here

Figure 4

0 Answers
Related