iOS tableView表视图设置背景图片
来源:互联网 发布:二胡软件 编辑:程序博客网 时间:2024/05/17 08:49
经常遇到要给tableView设置背景图片的问题,但如果直接设置背景 backgroundView的话,背景图不会显示,原因是 tableView上的cell默认是不透明的颜色,所以解决方法是 让 cell透明即可:
1.给tableView设置背景view
UIImageView *backImageView=[[UIImageViewalloc]initWithFrame:self.view.bounds];
[backImageView setImage:[UIImageimageNamed:@"liaotianbeijing"]];
self.tableView.backgroundView=backImageView;
2.让cell透明
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"METext"forIndexPath:indexPath];
cell.backgroundColor=[UIColor clearColor];//关键语句
[cell setCellInfo:dic];//自定义类目方法
return cell;
}
1.给tableView设置背景view
UIImageView *backImageView=[[UIImageViewalloc]initWithFrame:self.view.bounds];
[backImageView setImage:[UIImageimageNamed:@"liaotianbeijing"]];
self.tableView.backgroundView=backImageView;
2.让cell透明
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"METext"forIndexPath:indexPath];
cell.backgroundColor=[UIColor clearColor];//关键语句
[cell setCellInfo:dic];//自定义类目方法
return cell;
}
0 0
- iOS开发- tableView表视图设置背景图片
- iOS tableView表视图设置背景图片
- iOS tableView表视图设置背景图片
- ios TableView设置背景图片
- ios:设置视图背景图片的方法
- ios:设置视图背景图片的方法
- tableview设置背景图片
- 给TableView设置背景图片
- 设置tableView的背景图片
- 关于设置tableView的背景图片
- iphone 设置视图背景图片
- 视图控制器背景图片设置
- IOS开发-TableView表视图基础
- IOS开发-TableView表视图LV2
- iOS:tableView表视图顶部多余部分
- iOS之设置tableView背景图片/让UITableView自动滑动(定位)到某一行cell
- swift开发笔记3 - 设置tableview背景图片
- IOS 设置背景图片
- Rxjava的线程问题
- caffe学习笔记(10):Gradient descent optimization algorithm
- Redis 分页排序查询
- mysql加载Sakila样例数据库
- R语言变量的重命名和一些处理
- iOS tableView表视图设置背景图片
- hadoop集群搭建
- [GIT] 取消对某个文件的追踪
- JavaScript闭包中的this
- springMVC (五) annotation-driven
- java之九 基本输入输出流
- 山东省第六届ACM大学生程序设计竞赛-Lowest Unique Price(桶排序)
- Java中Vector ArrayList LinkedList之间的区别与联系
- 关于cmake is not able to compile a simple test program