stackiphone
stackiphone

Reputation: 1245

how to change the font color of the special characters in a UITextview text

i am using this code to show some text in UITextview...in ViewDidLoad Method

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

    };

    maintextview.text =combined;
    maintextview.textColor= [UIColor colorWithRed:0.376f green:0.282f blue:0.173f alpha:1.0f];

    maintextview.font = [UIFont fontWithName:@"Georgia" size:self.fontSize];

combined has the text which includes numeric charter also,how can i identify the numeric character and put brown color and change font to Georgia-Bold only of numercharacters.is it possible by using NSSanner or NSregular expression or something like that?. how to do this? Thanks in advance.

Upvotes: 0

Views: 529

Answers (2)

Prabhat Kasera
Prabhat Kasera

Reputation: 1149

alternate option is to make an HTML page and put web View instead of the TextView.

it saves your time.

Upvotes: 0

borrrden
borrrden

Reputation: 33421

You cannot do this on a regular text view. It does not allow formatting (although this is a greatly desired feature by many developers). What you need to do is use Core Text and NSAttributedString with a custom view. However, this is very difficult if you need to use selection, or have it be editable.

Upvotes: 1

Related Questions