0

Of the several questions I have reviewed here on the subject of changing font colors, I assume there is no way to do this, but I will try again.

I start with a fresh copy of the MasterDetail template in xcode. The array to be loaded onto the Master view is defined as NSMutableArray *_objects;

I replace the statement that normally inserts the date/time into the row with statements to put in a sentence, "Help me display this in red as shown below:

//[_objects insertObject:[NSDate date] atIndex:0]; // removed this line and replaced with next two.

NSString *loadme = [[NSString alloc] initWithFormat:@"Help me display this in red"];
[_objects insertObject:loadme  atIndex:0];

So, the question is, how would I change the display of this row on the Master view with red text? thanks for your time and expertise.

Since I think the answer to the above question is that it can't be done. Can you tell me how to put an image on the row before the text. That would be an even better solution. I suspect it has something to do with UITableViewCell, but i have no experience in this area.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2632340
  • 25
  • 1
  • 4
  • Possibly this question is more or less than same as yours http://stackoverflow.com/questions/14287386/change-string-color-with-nsattributedstring – Carl Veazey Aug 11 '13 at 18:46

1 Answers1

0

There are a couple of ways that you could make this work. One, as per the comment from @CarlVeazey is to use NSAttributedString (like this) so that you can store the text and the colour together.

Another option would be to have another array where you add the colour (UIColor instances) and then when you prepare the cell you can set the label text and textColor from the two arrays.

Community
  • 1
  • 1
Wain
  • 118,658
  • 15
  • 128
  • 151