当在tableView中添加cell数据时,我们会发现原本设置的tableView的背景颜色不见了,这是因为加载cell数据时,tableView的背景颜色被cell数据遮盖住了,此时,可以通过设置cell的背景颜色,从而使得界面的背景有颜色

- (void)viewDidLoad {
[super viewDidLoad];
  //此时不会显示在用户眼前
self.view.backgroundColor = [UIColor blueColor];
} #pragma mark - <UITableViewDataSource>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 50;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
} // 数据赋值
//设置tableViewCell的颜色,当加载数据后cell会遮盖tableView的背景颜色
cell.contentView.backgroundColor = [UIColor redColor];
cell.textLabel.text = [NSString stringWithFormat:@"%@--%zd", self.title, indexPath.row]; return cell;
}

最新文章

  1. angularJS(6)
  2. Session Tracking Approaches
  3. KPI绩效考核为何在国内不管用?
  4. windows命令行
  5. 初试visual studio2012的新型数据库LocalDB
  6. GLSL Entry point not found
  7. linux基础命令学习(一)
  8. 《数据通信与网络》笔记--TCP中的拥塞控制
  9. IE6存在的一些兼容
  10. 【转】关于C execlp函数的理解
  11. EhLib DBGridEh组件在Delphi中应用全攻略总结(转)
  12. AutoResetEvent类的使用
  13. WebService 的工作原理
  14. 小技巧:selenium java中如何使用chrome默认的profile
  15. 洛谷 P3797 妖梦斩木棒
  16. 免费Git客户端:sourcetree详细介绍
  17. BZOJ_1503_[NOI2004]郁闷的出纳员_权值线段树
  18. 复杂度定义 The Definition of Complexity
  19. this语句的知识点第五点
  20. Java编程的逻辑 (58) - 文本文件和字符流

热门文章

  1. &quot;简单&quot;的优化--希尔排序也没你想象中那么难
  2. LeetCode-40. 组合总和 II C++(回溯法)
  3. python Max retries exceeded with URL in requests
  4. WebJar的打包和使用  
  5. Python基础(@property)
  6. 你会用ES6,那倒是用啊!
  7. [cf1349D]Slime and Biscuits
  8. 前端:WebP自适应实践
  9. IDEA:Git stash 暂存分支修改的代码
  10. processon刷文件的骚操作