• 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
Visual alignment problems when using NSText drawAtPoint:withAttributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Visual alignment problems when using NSText drawAtPoint:withAttributes


  • Subject: Visual alignment problems when using NSText drawAtPoint:withAttributes
  • From: John Fox <email@hidden>
  • Date: Tue, 27 Sep 2005 20:12:56 -0700

Hello Nice Cocoa Folk:

I'm trying to draw some text that is vertically and horizontally aligned within an NSBezier path that is itself a circle (I'm making a label to represent the number of objects being dragged from my view). Here's a snippet of my code:

        myTextSize = [myLabel sizeWithAttributes:myAttributes];

        myTextPoint = myCircleRect.origin;

        myTextPoint.x += (myCircleRect.size.width / 2);
        myTextPoint.y += (myCircleRect.size.height / 2);

        myTextPoint.x -= (myTextSize.width / 2);
        myTextPoint.y -= (myTextSize.height / 2);

        [myLabel drawAtPoint:myTextPoint withAttributes:myAttributes];

The problem I'm seeing is that the visual alignment is not what I'm hoping for: the text is off center to the left. Am I missing something? I want my labels to resemble the labels that one sees in Mail.app dock icon to indicate the number of unread messages. I've experimented with boundingRectWithSize:options:attributes, and it seems to work better, but still didn't look exactly right, and, I need my app to run under 10.3.

Can some kind soul help me out, please?

Many thanks,

John

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Visual alignment problems when using NSText drawAtPoint:withAttributes
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: QTMovieView and NSViewAnimation
  • Next by Date: How do you fill an NSBezierPath with transparent color?
  • Previous by thread: Re: QTMovieView and NSViewAnimation
  • Next by thread: Re: Visual alignment problems when using NSText drawAtPoint:withAttributes
  • Index(es):
    • Date
    • Thread