iPad groupTableViewBackgroundColor broken?
Anyone know how to get the groupTableViewBackgroundColor on an iPad? This seems to be broken in 4.2. I've tried grabbing if from the view using the color picker, but when I reuse开发者_Go百科 it as the background color for another view it's a different shade of gray.
OK, so it turns out that
[UIColor groupTableViewBackgroundColor]
does not behave the same on iPad as on iPhone. The grouped table views actually have a gradient as a a background. I have found two possible solutions for my particular need, which are:
- Add whatever I need on the background onto the table view itself (give it a content inset if necessary)
- Set my own background color, solid or otherwise
The best way to set backgrounds for a UITableView (on iPhone and iPad) is to create a UIView, set it's backgroundColor property and the set it as the UITableView's backgroundView.
UIView *backgroundView = [[UIView alloc] initWithFrame:frame];
backgroundView.backgroundColor = [UIColor redColor];
self.tableView.backgroundView = backgroundView;
If you want to use an image as the background create a UIImageView and add it as a subview of the UIView.
EDIT: Sorry I misinterpreted your question.
精彩评论