Created
December 8, 2015 16:48
-
-
Save kristopherjohnson/5826441eebc7e8f15086 to your computer and use it in GitHub Desktop.
Snippet to programmatically set initial position of an Cocoa window
This file contains 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
import Cocoa | |
class MyInitiallyPositionedWindowController: NSWindowController { | |
override func windowDidLoad() { | |
super.windowDidLoad() | |
if let window = window, screen = window.screen { | |
let screenRect = screen.visibleFrame | |
let offsetFromLeft = CGFloat(200) | |
let offsetFromTop = CGFloat(200) | |
let offsetFromBottom = screenRect.maxY - window.frame.height - offsetFromTop | |
window.setFrameOrigin(NSPoint(x: offsetFromLeft, y: offsetFromBottom)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment