1.改变tableView的背景色
方法-、_tableView.backgroundColor=[UIColor redColor];
方法二、UIView *view=[[UIView alloc] init];
//view.backgroundColor=[UIColor greenColor];
_tableView.backgroundView=view;
_tableView.backgroundView.backgroundColor=[UIColor greenColor];
2.改变tableView的背景
方法—、tableView的backgroundView指向一个UIImageView对象,并将tableView上的cell背景色设为透明:
UIImageView *bgImgView=[[UIImageView alloc] init];
bgImgView.image=[UIImage imageNamed:@"a.jpg"];
_tableView.backgroundView=bgImgView;
改变cell的背景色为透明:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.backgroundColor=[UIColor clearColor];
cell.textLabel.text=@"123";
return cell;
}
方法二、在tableView的父视上添加背景图片,tableView颜色设为透明
UIImageView *bgImgView=[[UIImageView alloc] initWithFrame:self.view.frame];
bgImgView.image=[UIImage imageNamed:@"a.jpg"];
[self.view addSubview:bgImgView];
self.tableView.backgroundColor=[UIColor clearColor];