I have a large custom UITableView with UILabels in each row, and I’d like to display certain texts in Black or Green color.
I feed the cells with the NSString's from a NSArray. Suppose I want to display in black only the the NSString from index 30.
I’m Trying something like this, but it’s not working:
NSIndexPath *indexPathWithBlackText = [NSIndexPath indexPathForRow:30 inSection:[indexPath section]];
if (indexPath.row == indexPathWithBlackText.row) {
//Label with text in black
topLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
topLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
} else {
//Label with text in green
topLabel.textColor = [UIColor colorWithRed:0.122 green:0.467 blue:0.255 alpha:1.00];
}
Any hints on the right direction will be much appreciated. Thanks!
In this UITableViewDataSource delegate method:
Write this:
Make a method to determine if the row is black or not