UITableViewCell的背景设置
来源:互联网 发布:三菱伺服电机调试软件 编辑:程序博客网 时间:2024/06/11 22:37
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (!cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease]; } // cell.backgroundColor = [UIColor blueColor]; cell.contentView.backgroundColor = [UIColor blueColor]; return cell;}
cell.backgroundColor = [UIColor blueColor];
<span style="color:#ff6666;"> //cell本身就是个UIView,如果直接改cell的backgroundColor 会被contentview覆盖掉</span>
cell.contentView.backgroundColor = [UIColor blueColor];
但是如果到了编辑模式就会出现以下情况= =。是不是太丑了……
Cocoa提供的按钮背景色为透明。
因为ContentView被移开,下面是tableView的颜色,已经不是cell的一部分了
解决方案:
所以,最好的方式应该是通过cell.backgroundView来改变cell的背景。
按照文档说明,backgroundView始终处于cell的最下层,所以,将cell里的其它subview背景设为[UIColor clearColor],以cell.backgroundView作为统一的背景,应该是最好的方式
代码如下:
//把cell的图片背景改了 backgroundView ~~~~
UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabbar_bg"]]; cell.backgroundView = imageV;</span>
效果:
是不是很可爱~~~很和谐~~~~
0 0
- UITableViewCell的背景设置
- UITableViewCell的背景颜色设置
- UITableViewCell 的简单背景以及 选中背景设置
- UITableViewCell设置选中背景颜色
- UITableViewCell的背景
- 自定义UITableViewCell的背景
- UITableViewCell的背景
- 关于UITableViewCell的背景
- UITableViewCell的背景
- UITableViewCell的背景
- UITableViewCell的背景
- UITableViewCell点击不松手时Cell的背景设置
- cellForRowAtIndexPath UITableViewCell 选中后的背景颜色设置
- 自定义UITableViewCell的背景样式
- 自定义UITableViewCell的背景样式
- 自定义UITableViewCell的背景颜色
- 自定义UITableViewCell的背景样式
- 自定义UITableViewCell的背景样式
- C语言基础 - extern,移位与或非
- 客户端向服务端发送信息
- Qt学习之路_9(Qt中Item Widget初步探索)
- Codeforces Round#324 div.2 E
- C++之RAII惯用法 blog.csdn.net/hunter8777/article/details/6327704
- UITableViewCell的背景设置
- QTableView的表格项中加入图标的方法
- Struts实战-使用SSH框架技术开发学籍管理系统
- 关于拉格朗日乘子法与KKT条件
- 为什么c++抛出异常后还能对函数内的局部对象进行析构? http://segmentfault.com/q/1010000002498987
- DDoS deflate – Linux下防御/减轻DDOS攻击
- 加盐hash保存密码的正确方式(上)
- 排序算法时间复杂度
- URL编码解码以及常见压缩算法和加密