• 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
Rotate NSString... I give up :(
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rotate NSString... I give up :(


  • Subject: Rotate NSString... I give up :(
  • From: "Vitaly Ovchinnikov" <email@hidden>
  • Date: Wed, 6 Aug 2008 10:46:14 +0400

Hello,

I need to draw NSString rotated to 90 degrees. Now I have the code:

NSRect rcWhereToDraw = NSMakeRect(........); // <- rect is already
"rotated" here
[str drawInRect:rcWhereToDraw withAttributes:attributes]; // string
will be drawn non-rotated

as far as I know, I need something like this:

[[NSGraphicsContext currentContext] saveGraphicsState];
NSRect rcWhereToDraw = NSMakeRect(........);

float dx = NSMidX(rcWhereToDraw), dy = NSMidY(rcWhereToDraw);

NSAffineTransform *tr = [NSAffineTransform transform];
[tr translateXBy:-dx yBy:-dy]; // center or rect will be the center of rotation
[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:dx yBy:dy]; // move it back
[tr concat];

[str drawInRect:rcWhereToDraw withAttributes:attributes];
[[NSGraphicsContext currentContext] restoreGraphicsState];

This doesn't work, where am I wrong?
Thank you.
_______________________________________________

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

  • Follow-Ups:
    • Re: Rotate NSString... I give up :(
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: Using performSelector: on super
  • Next by Date: Re: Properties and memory management
  • Previous by thread: Re: KBML Generator/Parser
  • Next by thread: Re: Rotate NSString... I give up :(
  • Index(es):
    • Date
    • Thread