亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

改變iOS應(yīng)用中UITableView的背景顏色與背景圖片的方法

 更新時(shí)間:2016年03月29日 14:47:15   作者:ForeverYoung21  
這篇文章主要介紹了改變iOS應(yīng)用中UITableView的背景顏色與背景圖片的方法,將UITableView的header、footer設(shè)成clearColor時(shí)要注意實(shí)際效果是否真的變透明,需要的朋友可以參考下

改變UITableView的header、footer背景顏色

改變UITableView的header、footer背景顏色,這是個(gè)很常見的問題。之前知道的一般做法是,通過實(shí)現(xiàn)tableView: viewForHeaderInSection:返回一個(gè)自定義的View,里面什么都不填,只設(shè)背景顏色。但是今天發(fā)現(xiàn)一個(gè)更簡(jiǎn)潔的做法:

對(duì)于iOS 6及以后的系統(tǒng),實(shí)現(xiàn)這個(gè)新的delegate函數(shù)即可:

復(fù)制代碼 代碼如下:

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section {
 view.tintColor = [UIColor clearColor];
}

還可以改變文字的顏色:
復(fù)制代碼 代碼如下:

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section
{
 UITableViewHeaderFooterView *footer = (UITableViewHeaderFooterView *)view;
 [footer.textLabel setTextColor:[UIColor whiteColor]];
}

修改tableView的背景圖片

修改UITableView的背景圖片

1.圖片顯示為'PatternImage'模式。

復(fù)制代碼 代碼如下:

// viewDidLoad

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundImage"]];

// cellForRowAtIndexPath

cell.backgroundColor = [UIColor clearColor];


這種情況下背景圖片像地板磚一樣平鋪。拉動(dòng)tableView背景圖片會(huì)隨著動(dòng),若行數(shù)超過背景圖片的高度,會(huì)接著顯示下一張圖片。

2.正常的背景圖片。

復(fù)制代碼 代碼如下:

// viewDidLoad

self.tableView.backgroundColor= [UIColor clearColor];

UIImageView*imageView = [[UIImageView alloc]initWithImage:[UIImageimage Named:@"BackgroundImage"]];

self.tableView.backgroundView = imageView;

// cellForRowAtIndexPath

cell.backgroundColor = [UIColor clearColor];


這種情況下背景圖片不會(huì)動(dòng),即無論多少行看到的都是同樣的背景。

相關(guān)文章

最新評(píng)論