改變UITableView的header、footer背景顏色
改變UITableView的header、footer背景顏色,這是個很常見的問題。之前知道的一般做法是,通過實現tableView: viewForHeaderInSection:返回一個自定義的View,里面什么都不填,只設背景顏色。但是今天發現一個更簡潔的做法:
對于iOS 6及以后的系統,實現這個新的delegate函數即可:
修改UITableView的背景圖片
1.圖片顯示為'PatternImage'模式。
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundImage"]];
// cellForRowAtIndexPath
cell.backgroundColor = [UIColor clearColor];
2.正常的背景圖片。
self.tableView.backgroundColor= [UIColor clearColor];
UIImageView*imageView = [[UIImageView alloc]initWithImage:[UIImageimage Named:@"BackgroundImage"]];
self.tableView.backgroundView = imageView;
// cellForRowAtIndexPath
cell.backgroundColor = [UIColor clearColor];
新聞熱點
疑難解答