Re: How do I rotate text ?
Re: How do I rotate text ?
- Subject: Re: How do I rotate text ?
- From: Andreas Mayer <email@hidden>
- Date: Wed, 12 Jun 2002 23:54:16 +0200
Am Mittwoch den, 12. Juni 2002, um 21:33, schrieb RFM:
I want to rotate a line of text by 90 degrees
I don't know if there's an easier way, but you may use a custom view and
do something like this in your drawRect: method:
- (void)drawRect: (NSRect)rect
{
NSAffineTransform *transform = [NSAffineTransform transform];
NSGraphicsContext *context = [NSGraphicsContext currentContext];
NSMutableDictionary *attr = [NSMutableDictionary dictionary];
NSRectFill([self bounds]);
//[transform translateXBy:center.x yBy:center.y];
[transform rotateByDegrees:-angle];
[context saveGraphicsState];
[transform concat];
[attr setObject:[NSFont userFontOfSize:[NSFont
systemFontSize]*radius] forKey:NSFontAttributeName];
[(NSString *)[NSString stringWithString:@"test"]
drawAtPoint:NSMakePoint(10, 10) withAttributes:attr];
[context restoreGraphicsState];
}
I hope this is correct. I copied it from a larger example and deleted
everything I thought was unrelated. Anyway, I think you get the point. :)
If you like, I can mail you the whole thing. It's made from Apple's
DotView example and allows you to freely move, size and rotate a bezier
path (and the text I added to test NSString's drawAtPoint:withAttributes
method. ;-)).
bye. Andreas.
_______________________________________________
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.