What rect does NSTextFieldCell use to draw its contents?
What rect does NSTextFieldCell use to draw its contents?
- Subject: What rect does NSTextFieldCell use to draw its contents?
- From: Kyle Sluder <email@hidden>
- Date: Mon, 10 Dec 2012 11:13:43 -0800
It's my understanding that the intent of NSStringDrawing is to provide
the exact same drawing as NSTextFieldCell. But the following code
produces text that is offset by 2pt to the left from a standard
NSTextFieldCell:
@implementation MyTextFieldCell /* : NSTextFieldCell */
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
NSStringDrawingOptions options = 0;
if (self.truncatesLastVisibleLine)
options |= NSStringDrawingTruncatesLastVisibleLine;
if (!self.usesSingleLineMode)
options |= NSStringDrawingUsesLineFragmentOrigin;
[self.attributedString drawWithRect:[self
titleRectForBounds:cellFrame] options:options];
}
@end
I can't tell if I'm using the wrong rect or failing to pass the right
arguments to -drawWithRect:options:. Anyone have any clues?
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden