Re: Find color's change in a NSString (attributed)
Re: Find color's change in a NSString (attributed)
- Subject: Re: Find color's change in a NSString (attributed)
- From: Stephane Sudre <email@hidden>
- Date: Mon, 20 Feb 2006 17:36:37 +0100
On 20 févr. 06, at 17:18, Andrea Salomoni wrote:
Hi to all,
I have a text with some colors and I need to parse the text and know
the words with the color and change it.
I already parsed the text succesfully , but cannot find any
documentation about searching the color's change in a text.
Anyone can help me?
Hmm, maybe this can work:
tIndex=0;
tLength=[tAttributedString length];
while (tIndex<tLength)
{
tRangeLimit=NSMakeRange(tIndex,tLength-tIndex);
tAttributes=[tAttributedString attributesAtIndex:tIndex
longestEffectiveRange:&tRangeOut inRange:tRangeLimit];
if (tAttributes!=nil)
{
NSColor * tForeColor;
tForeColor=[tAttributes objectForKey:NSForegroundColorAttributeName];
if ([tForeColor isClosedTo:myColor]==YES) // isClosedTo is a method
I use in a category of NSColor
{
// Do my stuff
}
tIndex+=tRangeOut.length;
}
else
{
break;
}
}
_______________________________________________
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