UITableViewCell 间隔颜色

- (UITableViewCell *)tableView:(UITableView *)mtableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	NSInteger row = [indexPath row];
	static NSString *CellIdentifier = @"cai-sflist-cell";
	
	UITableViewCell *cell = (UITableViewCell*)[mtableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (!cell){
		cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
	}
	NSDictionary *caiDictionary = [list objectAtIndex:row];

	UIView *v = [[UIView alloc] initWithFrame:cell.frame];
	if(row % 2 ){
		v.backgroundColor = [UIColor whiteColor];
	}else{
		UIColor *backgroundColor = [UIColor colorWithRed:(251.0/255.0) green:(248.0/255) blue:(243.0/255) alpha:1.0];
		v.backgroundColor = backgroundColor;
	}
	cell.backgroundView = v;
	[v release];

	cell.textLabel.text = [caiDictionary objectForKey:@"english"];
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	
	return cell;
}


- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
	cell.backgroundColor = [UIColor clearColor];
}

你可能感兴趣的:(UITableViewCell)