改变iOS应用中UITableView的背景颜色与背景图片的方法
改变UITableView的header、footer背景颜色
改变UITableView的header、footer背景颜色,这是个很常见的问题。之前知道的一般做法是,通过实现tableView:viewForHeaderInSection:返回一个自定义的View,里面什么都不填,只设背景颜色。但是今天发现一个更简洁的做法:
对于iOS6及以后的系统,实现这个新的delegate函数即可:
-(void)tableView:(UITableView*)tableViewwillDisplayFooterView:(UIView*)viewforSection:(NSInteger)section{
view.tintColor=[UIColorclearColor];
}
还可以改变文字的颜色:
-(void)tableView:(UITableView*)tableViewwillDisplayFooterView:(UIView*)viewforSection:(NSInteger)section
{
UITableViewHeaderFooterView*footer=(UITableViewHeaderFooterView*)view;
[footer.textLabelsetTextColor:[UIColorwhiteColor]];
}
修改tableView的背景图片
修改UITableView的背景图片
1.图片显示为'PatternImage'模式。
//viewDidLoad
self.tableView.backgroundColor=[UIColorcolorWithPatternImage:[UIImageimageNamed:@"BackgroundImage"]];
//cellForRowAtIndexPath
cell.backgroundColor=[UIColorclearColor];
热门推荐
9 家长会简短祝福语
10 长辈生日祝福语简短大全
11 新年祝福语创意简短霸气
12 客户去旅游祝福语简短
13 女孩生日祝福语简短的话
14 公司年会祝福语简短最好
15 病人的生日祝福语简短
16 年末祝福语简短小清新
17 简短的几句新年祝福语
18 小班老师六一祝福语简短