UITableView cell with background image

后端 未结 9 806
無奈伤痛
無奈伤痛 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:56

    You can set UITableViewCell background color/image, By following delegate method

     - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath
     *)indexPath  
    {      
         if((indexPath.row)==0)  
           cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]]; //set image for cell 0
    
         if (indexPath.row==1)  
           cell.backgroundColor = [UIColor colorWithRed:.8 green:.6 blue:.6 alpha:1]; //set color for cell 1
    
         tableView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"cloud.jpg"]]; //set image for UITableView
    
      }
    

提交回复
热议问题