NSString drawInRect - Vertically Align
NSString drawInRect - Vertically Align
- Subject: NSString drawInRect - Vertically Align
- From: vance <email@hidden>
- Date: Wed, 8 Aug 2007 18:55:48 -0700
Hello,
How do I *vertically* align text drawn using [NSString drawInRect:
withAttributes]?
Here is a picture of the application window from the code below:
http://grkov.com/sample.png
The code:
- (void)drawRect:(NSRect)rect
{
[self drawRoundedRect:[self bounds] inView:self];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle
defaultParagraphStyle] mutableCopy];
[paragraphStyle setAlignment:NSCenterTextAlignment];
NSDictionary *textAttribs;
textAttribs = [NSDictionary dictionaryWithObjectsAndKeys: [NSFont
fontWithName:@"Lucida Grande" size:14],
NSFontAttributeName, paragraphStyle,
NSParagraphStyleAttributeName, nil];
NSString *dropImageText = @"Drop Image Here";
[dropImageText drawInRect:NSInsetRect([self bounds], 20, 20)
withAttributes:textAttribs];
}
Thanks!
Vance
_______________________________________________
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