Created
August 27, 2020 00:21
-
-
Save goranmoomin/a85e0f441ab157c8ea429b54537198e3 to your computer and use it in GitHub Desktop.
Making a window controller with a popover appearance (which didn't go into code, but might be useful in the future)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func detachableWindow(for popover: NSPopover) -> NSWindow? { | |
let windowController = NSStoryboard.main?.instantiateController(withIdentifier: .replyWindowController) as! NSWindowController | |
let replyPopupViewController = windowController.contentViewController as! ReplyPopoverViewController | |
replyPopupViewController.comment = comment | |
let window = windowController.window! | |
window.setContentSize(popover.contentSize) | |
window.isMovableByWindowBackground = true | |
let visualEffectView = window.contentView as! NSVisualEffectView | |
visualEffectView.state = .active | |
visualEffectView.material = .popover | |
let maskImage = NSImage(size: NSSize(width: 16, height: 16), flipped: false) { rect in | |
let bezierPath = NSBezierPath(roundedRect: rect, xRadius: 8, yRadius: 8) | |
NSColor.black.set() | |
bezierPath.fill() | |
return true | |
} | |
maskImage.capInsets = NSEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) | |
visualEffectView.maskImage = maskImage | |
return window | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment