美文网首页ios
UITableView设置背景图

UITableView设置背景图

作者: SHUTUP | 来源:发表于2015-06-18 15:27 被阅读1809次

经常遇到要给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;

}

相关文章

网友评论

    本文标题:UITableView设置背景图

    本文链接:https://www.haomeiwen.com/subject/uwesqttx.html