UITableView backgroundColor always gray on iPad

前端 未结 9 1462
小蘑菇
小蘑菇 2020-11-30 18:02

When I set the backgroundColor for my UITableView it works fine on iPhone (device and simulator) but NOT on the iPad simulator. Instead I get a lig

9条回答
  •  孤城傲影
    2020-11-30 18:40

    I also got this kind of problem. The UITableView background color will be always groupTableViewBackgroundColor no matter what I set.

    The symptom is like this issue - UITableView is resetting its background color before view appears

    After I set the background color in init function, it is correct. In viewDidLoad and viewWillAppear stage, it is correct. However, in viewDidAppear, the background color is reset to its default color.

    The accepted answer does not work now.

    [myTableView setBackgroundView:nil];
    [myTableView setBackgroundView:[[UIView alloc] init]];
    

    Here is my solution. Just set the tableView's background color in viewDidLoad function rather than init or viewWillAppear.

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tableView.backgroundColor = [UIColor clearColor];
    }
    

提交回复
热议问题