我看过有关 ios 4.2 的 UITableView 背景颜色的各种帖子,但我似乎无法更改背景颜色。
UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;
我已将此代码放入 viewDidLoad 中,但它不会改变颜色。我的 UITableView 是 UIViewController 内的 IBOutlet,带有 UITableViewDelegate 和 UITableViewDataSource,所以我在 viewDidLoad 时认为 UITableView 已经呈现,我无法更改其背景颜色。
编辑* - UITableView 已分组
最佳答案
尝试将 TableView 的背景设置为nil,并设置 TableView 的背景颜色
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.myTableView.backgroundView = nil;
self.myTableView.backgroundColor = [UIColor blackColor];
}
关于ipad - UITableView背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6724243/