Search code examples
iosuitableviewbackgrounduicolor

TableView cell on iPad refusing to accept clear color


I am using a github project called SWTableViewCell.h by Chris Wendel. On the iPhone, clear color works. However, on an iPad it refuses to make the tableview cell clear. Instead, it makes it white. I have been wracking my brain how to fix this but cannot. I have even tried to set the background based on a png, but it just will not work. What types of alternatives can I go about to solve this?


Solution

  • In the documentation for the project on GitHub, there is a method:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        // Set background color of cell here if you don't want default white
    }
    

    Change it to this:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        [cell setBackgroundColor:[UIColor clearColor]];
    }