drawing a simple string with NSFont
drawing a simple string with NSFont
- Subject: drawing a simple string with NSFont
- From: Scott F Bayes <email@hidden>
- Date: Tue, 7 Aug 2007 18:29:23 +0900
I'm trying to draw an NSString on a NSView while in its drawRect, using
- (void)drawInRect:(NSRect)aRect withAttributes:(NSDictionary *)
attribute
from the AppKit NSString additions. I can draw the string where I
want to without problem, but I want to select a font and a font size.
"Simple Text Drawing" in the Drawing Guide says:
"For an NSString object, you can apply basic attributes (such as
font, color, and style settings) to the entire string during
drawing." Perfect!
It sounds like setting font&size can be accomplished either with the
NSDictionary *withAttributes for drawInRect above, or by [myFont set]
while in drawRect.
I find I can create what appears to be a valid NSFont, no problem.
But [myFont set] in drawRect doesn't appear to do anything, and I
don't know how to construct the NSDictionary mentioned above,
assuming it's what I need; I can't figure out what key to use.
Documentation has led me through enough twists and turns that I'm now
thoroughly confused.
Any advice or a short example would be appreciated.
Scott B
_______________________________________________
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