Author
Travis Kirton


Masking

You can use any visible object to mask a view.

view.mask = shape

When doing so the masked view will be transparent wherever the mask is transparent. So, if you use a semi-transparent image, or a shape with opacity < 1.0, the masked object will also be slightly visible.

Example

let img = Image("chop")!
img.center = canvas.center
canvas.add(img)

img.mask = Circle(center: img.bounds.center, radius: img.height/2)