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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.