UITableView cell with background image

后端 未结 9 803
無奈伤痛
無奈伤痛 2020-11-29 17:14

i have a UITableView, where theres 3 images. 1 for the selected Cell, 1 for the Cell background, and 1 for the TableView background.

My selected Cell, is working jus

9条回答
  •  被撕碎了的回忆
    2020-11-29 17:53

    //this concept is right but one problem is create when ur fastly scroll in uitable View then cell background color slowly change and indexing problem 
    
    for Cell
    
        UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
        myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
        cell.selectedBackgroundView = myBackView;
        [myBackView release];
    
    for table
    
        aTableView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"cloud.jpg"]];
        aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    //this concept is right but one problem is cteare when ur fastly scroll in uitable View then cell background color slowly change and indexing problem  so use this code
    
    for Cell
    
    
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
       cell.backgroundColor = (indexPath.row%2)?[UIColor lightGrayColor]:[UIColor grayColor];
    }
    

提交回复
热议问题