'In a MacOS NSView, how to crop (circle crop) an MTKRenderView or MTKView?

This question is about NSView, not UIView. Thus, this question is about MacOS, not iOS.

(It is trivial to crop anything in iOS. This question is about MacOS - NSView.)

I have a vanilla NSView and, using the excellent Agora, a MTKView is added as a subview (specifically an MTKRenderView).

I just want to crop the subview - the MTKView - to a circle (any shape would be fine!)

I've tried everything. I thought maybe just using a Box would do it. (Box usually crops everything.) But no.

I want to crop it to a circle, that is to say with transparency outside the circle.

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source