UITableViewCell clear background - Grouped UITableView

后端 未结 6 1279
无人共我
无人共我 2021-02-10 21:45

I am trying to display my data in a grouped table as below :

\"enter

As you can

相关标签:
6条回答
  • 2021-02-10 22:18

    Just try with it:

    Set the cell background view to YourcellImage & cells background color to clear color.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath             
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) 
        {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    
            [cell setBackgroundColor:[UIColor clearColor]];
            UIImage *backgroundImage = nil;
            UIImageView *backgroundView = nil;
            backgroundImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"YourYellowCellImage"ofType:@"png"]];
            backgroundView = [[UIImageView alloc]initWithImage:backgroundImage];
            backgroundView.frame = CGRectMake(0, 0, 600, 80); // Over here give your cell size
            cell.backgroundColor = [UIColor clearColor];
            cell.backgroundView =backgroundView;
    
            [backgroundView release];   
       }
       //Over your set your Label Value    
       return cell;
    }
    
    0 讨论(0)
  • 2021-02-10 22:24

    Try

    - (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath
    
    {
    
      cell.backgroundColor = [UIColor clearColor];
    
    }
    
    0 讨论(0)
  • 2021-02-10 22:28

    Clearing the background in the cellForRowAtIndex method should work

    [cell setBackgroundColor:[UIColor clearColor]];
    

    try also to clear the background in the viewWillAppear and if something weird happens, clear the project and rebuild.

    0 讨论(0)
  • 2021-02-10 22:33

    I was facing the same problem. And got to know It has nothing to do with cell's background.

    The issue is with background of the tableview which causes this weird corners, So

    self.tableview.backgroundColor = [UIColor clearColor];
    

    in viewWillAppear will solve the issue :)

    0 讨论(0)
  • 2021-02-10 22:42

    Try this code.....

    customerTable.separatorColor = [UIColor clearColor];
    
    0 讨论(0)
  • 2021-02-10 22:44

    Try

    customerTable.backgroundColor = [UIColor clearColor];
    customerTable.opaque = NO;
    customerTable.backgroundView = nil;
    
    0 讨论(0)
提交回复
热议问题