經(jīng)常遇到要給tableView設(shè)置背景圖片的問題,但如果直接設(shè)置背景 backgroundView的話,背景圖不會顯示,原因是 tableView上的cell默認是不透明的顏色,所以解決方法是 讓 cell透明即可:
1.給tableView設(shè)置背景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];//關(guān)鍵語句
[cell setCellInfo:dic];//自定義類目方法
return cell;
}