为UITableView的列设置间隔颜色

为不同的列设置间隔颜色(alternate color ),可以方便用户观看app的内容,在UTTableView中设置间隔颜色需要重写下面的willDisplayCell:forRowAtIndexPath方法

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    if( [indexPath row] % 2) {

        [cell setBackgroundColor:[UIColorwhiteColor]];

    }

    else {

        [cell setBackgroundColor:[UIColorgrayColor]];

    }

}

posted @ 2012-12-29 13:20  Jake Lin  阅读(823)  评论(0编辑  收藏  举报