Re: Sizing text in a box
Re: Sizing text in a box
- Subject: Re: Sizing text in a box
- From: "T.G. McLean" <email@hidden>
- Date: Wed, 6 Feb 2002 08:28:52 -0700
Ben Haller wrote:
Is there really no way to find out the
extent my text will draw to before I actually draw it?
Ben --
Once again, Aaron brings up an example in his text (Chapter 15):
_____
// Display the string in the middle of a rect.
- (void) drawStringCenteredIn:(NSRect)r
{
NSPoint stringOrigin;
NSSize stringSize;
stringSize = [string sizeWithAttributes:attributes];
NSLog(@"String size: <%f,%f>", stringSize.width, stringSize.height);
stringOrigin.x = r.origin.x + (r.size.width - stringSize.width)/2;
stringOrigin.y = r.origin.y + (r.size.height - stringSize.height)/2;
[string drawAtPoint:stringOrigin withAttributes:attributes];
}
_____
The only problem with this (did you mention this just recently?) is that
it tends to clip large letters. Still poking...
-- TG
------------------
T.G. McLean
email@hidden
email@hidden
"The mass of men lead lives of quiet desperation." -- Thoreau.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.