Skip navigation.
 
mlRe: multi coloured string
FROM : Shawn Erickson
DATE : Wed Nov 07 22:52:48 2007

On 11/7/07, Erfan Aleemullah <erfan.<email_removed>> wrote:
> Hi all,
> I have an issue with NSAttributedString -
>
> I am currently combining several strings into one string using
> -stringByAppendingString- and then converting this string into
> AttributedString for output -
>
> but each String has a distinct colour (user defined) which the
> NSAttributedString object does not recognize - it just colours the whole
> concatenated string the same colour based on the value it grabs from
> NSDictionary
>
> What is the best way to output a concatenated, multicolored string ?


Simple create an attributed string with each string range colored as needed...

Your example code appends strings together and then creates an
attributed string with what looks to be the last color specified,
which is not what I think you want.

Why not use NSMutableAttributed string? You would then create an
NSAttributed string for each string with the color information for
that string. Once you have that attributed string append it to your
mutable attributed string.

-Shawn

Related mailsAuthorDate
mlmulti coloured string Erfan Aleemullah Nov 7, 22:37
mlRe: multi coloured string Shawn Erickson Nov 7, 22:52
mlRe: multi coloured string I. Savant Nov 7, 22:53
mlRe: multi coloured string Shawn Erickson Nov 7, 22:55