• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSString drawInRect - Vertically Align
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: mouseMoved: or multiple trackingRects?
  • Next by Date: Re: string encoding in NSMutableData
  • Previous by thread: Re: Socket communications
  • Next by thread: Issues With JAWT_MacOSXDrawingSurfaceInfo
  • Index(es):
    • Date
    • Thread