0

I'm trying to make a semi-transparent window (white), and have a view that sits over the top of it to make it appear clear again.

Essentially, it looks like:

What is currently looks like

And what I want it to look like is:

What it should look like

My window is defined like:

window!.alphaValue = 0;
// Set level to screensaver level
window!.level = 1000
window!.backgroundColor = NSColor.white;
window!.animator().alphaValue = 0.5;

A white window with 50% opacity. The view on top contains a single CAShapeLayer. This layer is defined like:

shapeLayer = CAShapeLayer();
shapeLayer!.lineWidth = 1.0;
shapeLayer!.strokeColor = NSColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1).cgColor;
shapeLayer!.fillColor = NSColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor;

This window is movable by the user, so I need some kind of dynamic way to clear the contents of the main window and show through to whatever is underneath (the desktop, another application, etc)

David
  • 1,326
  • 9
  • 16
  • Possible duplicate of [this question](http://stackoverflow.com/questions/16512761/calayer-with-transparent-hole-in-it). You would just need to adapt the code for a rectangle. – Benjamin Lowry Oct 08 '16 at 14:17
  • I was just looking at that, and I don't think it works like that. That is about covering an existing View in the application with a Layer containing a hole. I want to be able to see whatever is behind my applications window. – David Oct 08 '16 at 14:27

0 Answers0