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