开发者

Table view property in iphone [duplicate]

This question already has answers here: Closed 11 years ago.

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜