小编Pra*_*een的帖子

如何设置tableView的背景颜色

我一直尝试但无法成功设置TableView的backgroundColor.设置tableView.backgroundColor和/或cell.backgroundColorclearColor当父视图控制器是没有工作UIViewContoller.

我的nib文件结构是

FileOwner
View
UITableView
Run Code Online (Sandbox Code Playgroud)

(注意:我将TableView设置为groupsTable部分)

第一次尝试,我UIView在代码中创建了viewDidLoad

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, 300)] autorelease;
[view setBackgroundColor:UIColor blueColor]; // color it just to see if it is created at the right place
[self.tableView sendSubViewToBack:view];
Run Code Online (Sandbox Code Playgroud)

它有效,但它隐藏了细胞的内容.我能够看到标题的内容,但不能看到单元格内容.(但是当我更改视图的坐标(0,150,160,300)时,我能够看到单元格的内容,但随后它会松开tableview的backgroundColor.

第二次尝试,我创建了imageView

View
ImageView
UITableView
Run Code Online (Sandbox Code Playgroud)

并设置self.tableView.backgroundColor = [UIColor clearColor];但没有奏效.

我用谷歌搜索,但没有和平的答案.

iphone xcode uitableview uiviewcontroller

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

iphone ×1

uitableview ×1

uiviewcontroller ×1

xcode ×1