UITableView 方法总结

来源:互联网 发布:淘宝怎么退订服务 编辑:程序博客网 时间:2024/05/16 00:28

1. 给tableview添加一个背景图片

self.tableView.backgroundColor=[UIColor clearColor];

 UIImageView *imageview = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"home_bg.png"]];

 [self.tableView setBackgroundView:imageview];

2. 给tableview中的cell添加背景图片

重写函数

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

 cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"58rowWrap.png"]]; //cell的背景图

 cell.textLabel.backgroundColor = [UIColor clearColor];

}

3.去掉tableview中的分割线

separatorStyle = UITableViewCellSeparatorStyleNone;

4.tableview中的cell加载背景图

[cell.contentView addSubview:]

5.实现如下图

如下图

a.去掉tableview中的分割线

b.设置separate的值为none,设置tableview的background为clearcolor

c.在cell中添加UILabel