• 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
Re: Centering text drawn to screen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Centering text drawn to screen


  • Subject: Re: Centering text drawn to screen
  • From: email@hidden
  • Date: Thu, 13 Jun 2002 22:29:27 +0200

On jeudi, juin 13, 2002, at 09:54 , Ryan McPherson wrote:

Hello,

I am writing a screensaver that flashes text on the screen using NSString's
drawInRect:withAttributes: method. I have been successful so far, but the
text is drawn left-adjusted to the rectangle I'm drawing in and I want it to
be centered. I couldn't find an attribute that handles this in the
documentation.

Any suggestions?

I would suggest two things:

1) compute your String bounding rect using the APIs:

- (NSSize)sizeWithAttributes:(NSDictionary *)attributes;

2) Use the ScreenSaver API

SSCenteredRectInRect

You can easily get the frameRect of the Screen.
_______________________________________________
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.

References: 
 >Centering text drawn to screen (From: Ryan McPherson <email@hidden>)

  • Prev by Date: Re: Centering text drawn to screen
  • Next by Date: Re: Modem and serial ports
  • Previous by thread: Re: Centering text drawn to screen
  • Next by thread: Re: Centering text drawn to screen
  • Index(es):
    • Date
    • Thread