Skip to content

Instantly share code, notes, and snippets.

@mashhoodr
Last active December 29, 2015 21:19
Show Gist options
  • Save mashhoodr/7729351 to your computer and use it in GitHub Desktop.
Save mashhoodr/7729351 to your computer and use it in GitHub Desktop.
A snippet for styling the NSTextfields properly [http://imars.info/styling-nstextfields-cocoa-development/]
- (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView {
NSImage *img = [NSImage imageNamed:@"tf"];
[img drawAtPoint:NSPointFromCGPoint(CGPointMake(0, 0))
fromRect:NSZeroRect
operation:NSCompositeSourceOver
fraction:1];
cellFrame.origin.x += 10;
cellFrame.origin.y += 16;
[super drawWithFrame:cellFrame inView:controlView];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)textObj
delegate:(id)anObject
start:(NSInteger)selStart
length:(NSInteger)selLength {
aRect.origin.x += 10;
aRect.origin.y += 16;
[super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment