ipad - UITableView背景颜色

标签 ipad uitableview

我看过有关 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/

相关文章:

ios - 如果 objective-c 的 uitableview 中没有新行,如何停止滚动 uitableview?

ios - 如何在表格 View 中隐藏单元格后删除空白间距

ios - 将通用应用程序切换为 iPhone 专用应用程序

javascript - iOS UIAutomation UIAElement.isVisible() 抛出陈旧的响应?

ios - Objective C 中的表单验证

swift - 对高度更高的 uitableviewcell 中的 View 给予底部约束

iphone - 如何从应用程序商店为应用程序购买额外的应用程序内商品?

iphone - 当 iDevice 使用 3G/UMTS/Edge 时检测已建立的 VPN

swift - 使 TableViewCells 从 Storyboard Prototype 单元格中出列?

ios - 快速限制阵列容量会更有效吗?