Transparent background in grouped UITableView - iPhone

前端 未结 4 1797
再見小時候
再見小時候 2020-12-30 00:50

I want to make the grouped UITableView transparent. I partially succeded with the following code:

UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0         


        
相关标签:
4条回答
  • 2020-12-30 01:28

    Instead of using

    UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0.0];
    historyTable.backgroundColor = bgColor;
    

    Just use:

    historyTable.backgroundColor = [UIColor clearColor];
    

    That also clears up the memory leak you were creating.

    0 讨论(0)
  • 2020-12-30 01:33

    for me it worked finaly after setting both to nil/clear:

    [myTableView setBackgroundView:nil];
    [myTableView setBackgroundColor:[UIColor clearColor]];
    
    0 讨论(0)
  • 2020-12-30 01:41

    remove UITableView backgroundView

    xxx.backgroundView = nil;
    

    This is necessary on iPad builds. When compiling to run on iPad and iPhone, check the tableView responds to the selector with ...

    if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) {
        [self.tableView setBackgroundView:nil];
    }
    
    0 讨论(0)
  • 2020-12-30 01:52

    I had this issue and found that there was no difference between using:

    [[UIColor alloc] initWithWhite:1 alpha:0.0];
    

    and using:

    [UIColor clearColor];
    

    I tried both of these and still had the little black corners on my table view.

    I also tried setting the backgroundView to nil as suggested, but this didn't work either.

    I solved this by setting the backgrounds of the individual cells to transparent in the cellForRowAtIndexPath method:

    cell.backgroundColor =  [UIColor clearColor];
    

    Of course, this has the side effect that your cells themselves are transparent, which isn't ideal for everyone, but it ok for me in this case.

    0 讨论(0)
提交回复
热议问题