Skip to content

Instantly share code, notes, and snippets.

@aspitz
Created June 18, 2013 19:44
Show Gist options
  • Save aspitz/5808624 to your computer and use it in GitHub Desktop.
Save aspitz/5808624 to your computer and use it in GitHub Desktop.
Category code to position a window based on the upper right hand corner of the screen
#import "NSWindow+Utilities.h"
@implementation NSWindow (Utilities)
- (void)setTopLeftRelativeToMainScreen:(CGPoint)topLeftPt{
CGRect mainScreenVisibleFrame = NSScreen.mainScreen.visibleFrame;
CGPoint pt = CGPointZero;
pt.x = topLeftPt.x;
pt.y = mainScreenVisibleFrame.origin.y + mainScreenVisibleFrame.size.height - topLeftPt.y;
[self setFrameTopLeftPoint:pt];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment