Search code examples
iphoneiosnsstringuicolorcore-text

Font color doubts


i have this code to set a DB(sqlite)text into my view.i just draw the text in view using core text..

NSMutableString *combined = [NSMutableString string];

for(NSUInteger idx = 0; idx < [delegatee.allSelectedVerseEnglish count]; idx++) {
    [combined appendFormat:@"  %d %@", 
     idx + 1, 
     [delegatee.allSelectedVerseEnglish objectAtIndex:idx]];
}

self.multiPageView.text =combined;

delegatee.allSelectedVerseEnglish this is the array...and between each sentence of the text i put numbers like this 1 haii this is nipin 2 haii this is stack overflow 3 etc etc ..like that..i am able to change the text color of all the text includes the numbers ..but i need to put "red"color to numbers .how to change the color of the numbers in the above code.is that possible?. thanks in advance.


Solution

  • You need to use an NSMutableAttributedString and set the NSForegroundColorAttributeName value using the setAttributes:range: method.