注:
uitable在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
設定顏色,是無效的。
正確設定顏色的位置是:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
示例=========================================================================================
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView==main_friend_table) {
if(indexPath.row % 2 == 1){
[cell setBackgroundColor:[UIColor grayColor]];
}
else{//indexPath.row % 2 == 0
[cell setBackgroundColor:[UIColor whiteColor]];
}
}
}