• 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: changing the default color for text drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing the default color for text drawing


  • Subject: Re: changing the default color for text drawing
  • From: Douglas Davidson <email@hidden>
  • Date: Fri, 11 May 2007 09:23:34 -0700


On May 11, 2007, at 8:28 AM, Kenny Leung wrote:

We are using NSAttributedString for drawing pretty complicated text which sometimes has multiple colors. Now we find ourselves wanting to draw the same text on different backgrounds, which means that we want the default text color to be different. e.g. go from black text on a white background to white text on a black background. Is there a way to just change the default color that text is drawn in without affecting the rest of the attributes? It would be very onerous to go back and change everything so that we can specify the default text color when these strings are created.

Not directly. I'm not sure that I understand exactly what you want to achieve, but let me throw out some suggestions:


- use mutable attributed strings, and go through and set the color for those ranges that would otherwise have the default color; you can use a custom attribute to mark them if need be
- use an NSColor subclass, an abstract color whose actual value you can change when you need to
- use an NSAttributedString subclass that returns a suitable color when there is no value for the foreground color attribute
- use NSLayoutManager for your drawing, and set the color in temporary attributes for those regions where there is no color set on the text


Douglas Davidson

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >changing the default color for text drawing (From: Kenny Leung <email@hidden>)

  • Prev by Date: Re: Scope variable pattern
  • Next by Date: Re: Scope variable pattern
  • Previous by thread: Re: changing the default color for text drawing
  • Next by thread: Transparent NSTableView background == black background?
  • Index(es):
    • Date
    • Thread