• 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
Drawing a string with a clearColor background
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing a string with a clearColor background


  • Subject: Drawing a string with a clearColor background
  • From: Randall Meadows <email@hidden>
  • Date: Mon, 8 Dec 2008 14:31:09 -0700

I know I've seen a discussion of this, but my search-fu is weak today, apparently. Please feel free to reply in links to the answer, if you wish...

I'm trying to draw (in a view's -drawRect: method) a string over top an image background:

NSDictionary   *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
          font, NSFontAttributeName,
          textColor, NSForegroundColorAttributeName,
          [NSColor clearColor], NSBackgroundColorAttributeName,
          nil];
[text drawInRect:textBounds withAttributes:attrs];

draws the string in the correct text color and font, with a black rectangular background. I want the background image to show through the "holes" in the string I'm drawing. I tried adding

[[NSColor clearColor] set];
NSRectFill(textBounds);

before the -drawInRect: call, to no avail.  What am I missing?

Thanks!
randy
_______________________________________________

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: Drawing a string with a clearColor background
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Re: NSDictionary mutability test
  • Next by Date: Re: best practice to create Custom Objects represented by a image in a d-n-d operation
  • Previous by thread: Re: building a custom NSView with IB?
  • Next by thread: Re: Drawing a string with a clearColor background
  • Index(es):
    • Date
    • Thread