OSX 10.12, Xcode 8.0
I’m not entirely certain under which circumstances this is useful, but
[code language=”plain”]class invisibleWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
self.window?.isOpaque = false
self.window?.backgroundColor = NSColor.clear
}
}[/code]
is a thing of beauty.
If the view in the window’s contentViewController overrides override func draw(_ dirtyRect: NSRect), the effect is lost; if it merely contains elements like buttons and text fields, they will retain their opacity while the rest of the window vanishes.


This creates some interesting effects:
[code language=”plain”]class BlurView: NSView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
NSColor.cyan.set()
NSBezierPath.fill(self.bounds)
alphaValue = 0.5
}
}[/code]

(I have absolutely no idea why I would want to use this, but it needed to be recorded, and I shall remember window?.backgroundColor in the future.)
Jan 10 2017
The incredible invisible window
OSX 10.12, Xcode 8.0
I’m not entirely certain under which circumstances this is useful, but
[code language=”plain”]class invisibleWindowController: NSWindowController {override func windowDidLoad() {
super.windowDidLoad()
self.window?.isOpaque = false
self.window?.backgroundColor = NSColor.clear
}
}[/code]
is a thing of beauty.
If the view in the window’s contentViewController overrides override func draw(_ dirtyRect: NSRect), the effect is lost; if it merely contains elements like buttons and text fields, they will retain their opacity while the rest of the window vanishes.


[code language=”plain”]class BlurView: NSView {This creates some interesting effects:
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
NSColor.cyan.set()
NSBezierPath.fill(self.bounds)
alphaValue = 0.5
}
}[/code]
(I have absolutely no idea why I would want to use this, but it needed to be recorded, and I shall remember window?.backgroundColor in the future.)
By Extelligent Cocoa • Interface, Wiki • • Tags: NSWindowController