现在的位置: 首页 > 综合 > 正文

ios开发-设置UITableView/Cell背景设置

2014年06月11日 ⁄ 综合 ⁄ 共 552字 ⁄ 字号 评论关闭

自带的UITableView默认背景是白色的,在某些应用来说显得过于单调。

但是我们可以自定义背景,使我们的应用多彩一点。

下面介绍两种方法,设置UITableView背景或者Cell背景。

1.TableViewCell背景设置

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Default.png"]]; //cell的背景图
cell.textLabel.backgroundColor = [UIColor clearColor];
}


2.TableView背景设置


UIImageView *tableBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
[yourTable setBackgroundView:tableBg];
[tableBg release];

学习的路上,与君共勉。

抱歉!评论已关闭.