开发者

iPad groupTableViewBackgroundColor broken?

开发者 https://www.devze.com 2023-02-13 08:59 出处:网络
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 t

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:

  1. Add whatever I need on the background onto the table view itself (give it a content inset if necessary)
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消