UITableView的常用属性:

分割线颜色设置:

1》 设置separatorStyle: 分割线的颜色

方法:tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

2》 设置separatorColor 不用系统枚举的值,自己设定颜色的值

24bitRGB

R:8bit

G:8bit

B:8bit

===========

32bitRGBA

R:8bit

G:8bit

B:8bit

A:8bit 表示透明度alpha

# ff ff ff

设置值的时候用三原色的值比/255.0,这个结果是一个比值

方法:tableView.separatorColor = [[UIColor alloc] initWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:255/255.0];

3》 tableView的其他属性 整个tableView的header和footer

tableView.tableFooterView = [[UISwitch alloc] init]; // 底部

tableView.tableHeaderView = [[UIProgressViewalloc] init]; // 头部

************************************************************************

cell:内存的优化

当我们用tableView得cell显示数据的时候,有时候数据量很大,如果不处理内存,我们向下或者向上滑动的时候

会不停的开辟存储空间;

处理代码:

 1 // 每行显示的内容是什么
2 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
3 {
4
5 // 为我们创建的每个cell加标记
6 static NSString *identity = @"hero";
7 // 在创建cell时先从缓存迟中找被标记过的cell,当然这个缓存池是tableView创建的
8 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
9
10 // 如果找不到,在创建带标记的cell
11 if (cell == nil) {
12 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identity];
13 }
14
15 // 然后再给每个cell设置数据
16 CXBheorsModel *models = self.heros[indexPath.row];
17 cell.textLabel.text = models.name;
18 cell.detailTextLabel.text = models.intro;
19 cell.imageView.image = [UIImage imageNamed:models.icon];
20
21 // 当每个cell移出界面时,tablView会自动把它放入缓存池
22 return cell;
23
24 }
 
 

最新文章

  1. 高性能的JavaScript--数据访问(1)
  2. Java排序算法——希尔排序
  3. 移动端web开发进阶
  4. [ubuntu] Can not run OpenProj on Ubuntu
  5. 【Toolkit】关闭Closeable的简单工具类
  6. asp.net同时调用JS和后台的无效的解决
  7. Linux Kernel系列一:开篇和Kernel启动概要
  8. ASP.NET Session丢失问题原因及解决方案
  9. Linux下使Shell 命令脱离终端在后台运行
  10. nodejs+express-实现文件上传下载管理的网站
  11. React-propsType和defaultProps
  12. 优化读取纯真IP数据库QQWry.dat获取地区信息
  13. CF235D Graph Game
  14. 650. 2 Keys Keyboard复制粘贴的次数
  15. angular2.0 官网架构文档
  16. Could not get lock /var/lib/dpkg/lock的解决方法
  17. c++11 delete禁用函数
  18. Putty全屏/退出全屏快捷键
  19. iOS:转载sqlite3
  20. 记录:Web无引用无配置方式动态调用WCF服务

热门文章

  1. Netty 仿QQ聊天室 (实战二)
  2. static 静态域 类域 静态方法 工厂方法 he use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class 非访问修饰符
  3. android打包签名,从生成keystore到完成签名
  4. Android笔记之强大的buildConfigField
  5. PAT 天梯赛 L3-010. 是否完全二叉搜索树 【Tree】
  6. Python 参数校验的进化
  7. 如何配置DSI时钟频率
  8. backbone测试代码
  9. hdu Integer Inquiry 解题报告
  10. php封装数据库mysql, mysqli