UITableView backgroundColor always gray on iPad

前端 未结 9 1463
小蘑菇
小蘑菇 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:50

    If you are adding a UIViewController to another UIViewController you also need to set your view's background to clearColor in addition to UITableView or else you will get a white background instead of light grey.

    if ([myViewController.myTableView respondsToSelector:@selector(setBackgroundView:)]) {
        [myViewController.myTableView setBackgroundView:nil];
    }
    myViewController.myTableView.backgroundColor = [UIColor clearColor];
    myViewController.view.backgroundColor = [UIColor clearColor];
    

提交回复
热议问题