iOS tableView表视图设置背景图片

2015-01-21 0 784
iOS tableView表视图设置背景图片

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

遇见资源网 objective-c iOS tableView表视图设置背景图片 http://www.ox520.com/16079.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务