• 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
NSTextView text color alpha value?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView text color alpha value?


  • Subject: NSTextView text color alpha value?
  • From: Doug Brown <email@hidden>
  • Date: Mon, 11 Feb 2002 18:34:45 -0800

Is it possible to have transparent text in a text view? Here's a code snippet that doesn't seem to change the alpha value (it works great with different colors though):


(sAppend is the NSString to be appended)

NSMutableAttributedString *attStr;
NSAttributedString *temp;

if (!sAppend)
return;

attStr = [[NSMutableAttributedString alloc] initWithRTF:[chatTextView RTFFromRange:NSMakeRange(0, [[chatTextView string] length])] documentAttributes:nil];

temp = [[NSAttributedString alloc] initWithString:sAppend attributes:[NSDictionary dictionaryWithObjectsAndKeys:[[NSColor redColor] colorWithAlphaComponent:0.5], NSForegroundColorAttributeName, [NSFont userFixedPitchFontOfSize:0.0], NSFontAttributeName, nil]];

[attStr appendAttributedString:temp];

[chatTextView replaceCharactersInRange:NSMakeRange(0, [[chatTextView string] length]) withRTF:[attStr RTFFromRange:NSMakeRange(0, [attStr length]) documentAttributes:nil]];

[temp release];
[attStr release];


This code is kind of dirty right now but it does the job except for the alpha value. Any suggestions? Thanks.

Doug
_______________________________________________
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.

  • Prev by Date: Re: mount command
  • Next by Date: Obtaining data from finder drag onto cocoa application....
  • Previous by thread: Re: Drag n Drop on a NSControl : NSTextField?
  • Next by thread: Obtaining data from finder drag onto cocoa application....
  • Index(es):
    • Date
    • Thread