ios tableView中在不同行中显示不同的颜色

来源:互联网 发布:javascript用vs6.0编写 编辑:程序博客网 时间:2024/06/05 15:45
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row %2 == 1){
[cell setBackgroundColor:[UIColor yellowColor]];
}
else{//indexPath.row % 2 == 0
[cell setBackgroundColor:[UIColor lightGrayColor]];
}
[cell setSelectedBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_bg.png"]]];
}
0 0
原创粉丝点击