简体   繁体   中英

How to change the color of the view behind a UITableViewController?

I would like to change the color of the "view" behind my table view (the view controller is a UITableViewController). Currently, the view is black so when my table view slides in, via push, I see it through the transparent navigation bar during the transition. Is there a way to change its color? Thanks in advance.

I recently needed to do this in my app as well and found that: self.navigationController.view.backgroundColor = [UIColor whiteColor]; does the trick

Can you just set the background color of the tableViewController?

yourTableViewController.view.backgroundColor = [UIColor whiteColor];

Try, in your applicationDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window.backgroundColor = [UIColor whiteColor];
    // Override point for customization after application launch.
    return YES;
}

尝试这个:

self.view.superview.backgroundColor = [UIColor whiteColor];

You could set the backgroundColor on the backgroundView property of the tableView

UIView *backgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
backgroundView.backgroundColor = [UIColor redColor]; 
self.tableView.backgroundView  = backgroundView;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM