Table view property in iphone [duplicate]
Possib开发者_JAVA百科le Duplicate:
Table view property in iphone
I want to put the different different color of text of each row in Tableview in iPhone. How can I do this.
Use the following code:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"my cell id";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (nil == cell) {
cell = [[[UITableViewCell alloc] init] autorelease];
}
//your custom init of a cell here
...
if (indexPath.row == 0) {
cell.textLabel.textColor = [UIColor whiteColor];
} else if (indexPath.row == 1) {
cell.textLabel.textColor = [UIColor redColor];
} ...
return cell;
}
精彩评论