苹果ios开发者

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

经常遇到要给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; 
       
}
posted on 2015-12-29 16:52  苹果ios开发者  阅读(1135)  评论(0编辑  收藏  举报