简体   繁体   中英

How to change UITableView background color

I have the following codes:

    [self.tableView setBackgroundColor:[UIColor colorWithRed:0 green:185/255.0f blue:1 alpha:1];

I ended up with this:

结果

The navigation bar did change color as it is supposed to, but the rest of the table view is still plain grey. How do you fix this?

EDIT: I scroll my way to the bottom of the table view and it is fine. The search bar on the top comes from a search controller, maybe that is the problem. Here are a picture of the bottom:

表格视图的底部

You can try to change the backgroundview of the tableview:

UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, self.tableView.bounds.size.height)];
[backgroundView setBackgroundColor:[UIColor redColor]];
[self.tableView setBackgroundView: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