In article
,
"Seward S." wrote:
> I am interested in rotating an NSString 90 degrees, in order to
> display a label on a graph's vertical axis. I'm sure there is an easy
> way to do this in Cocoa, but have not been able to figure it out. Can
> someone point me in the right direction? Thanks.
#import <Cocoa/Cocoa.h>
@interface RotatedView : NSView
{
}
@end
@implementation RotatedView
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect]) != nil) {
// Add initialization code here
}
return self;
}
// example of drawing text at an angle.
- (void)drawRect:(NSRect)rect {
NSAffineTransform *t = [NSAffineTransform transform];
[t translateXBy:200. yBy:200.];
[t rotateByDegrees:40.]; // <-- or 90.
[t translateXBy:-200. yBy:-200.];
[t set];
[@"Hello World" drawAtPoint:NSMakePoint(100., 100.)
withAttributes:nil];
[[NSAffineTransform transform] set];
}
@end
>> Stay informed about: rotating an NSString