I have created a window without title by-
override func windowDidLoad() {
super.windowDidLoad()
self.window?.styleMask = NSBorderlessWindowMask
self.window?.movableByWindowBackground = true
}
I have set canBecomeKeyWindow by-
override var canBecomeKeyWindow:Bool
{
get{
return true
}
}
I have changed the background color of container view by-
override func drawRect(dirtyRect: NSRect) {
super.drawRect(dirtyRect)
var viewcolor = NSColor.whiteColor()
viewcolor.setFill()
NSRectFill(dirtyRect)
}
And a custom view is added as a subview to this container view and I changed background color of custom view by-
override func drawRect(dirtyRect: NSRect) {
super.drawRect(dirtyRect)
NSColor(SRGBRed: 0.8, green: 0.26, blue: 0.33, alpha:1.0).set()
NSRectFill(self.bounds)
}
Now when I do a toggleFullscreen like-
@IBAction func goFullScreen(sender: AnyObject) {
self.view.window?.toggleFullScreen(sender)
}
The whole area of screen is not filled. There is blank(black) background behind the window created. The app should fill the space, there shouldn't be black background in this screenshot
How can I fix this behaviour. Thanks for your help.
The problem is that your window is not resizable. Setting the
styleMask
toNSBorderlessWindowMask
inadvertently removedNSResizableWindowMask
.You should set the
styleMask
toNSBorderlessWindowMask | NSResizableWindowMask
.