最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

改變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),即無(wú)論多少行看到的都是同樣的背景。

相關(guān)文章

最新評(píng)論

专栏| 佛山市| 堆龙德庆县| 读书| 莆田市| 和平区| 秦皇岛市| 贡嘎县| 综艺| 施甸县| 黑山县| 禹州市| 平安县| 元阳县| 二连浩特市| 高碑店市| 个旧市| 扎兰屯市| 仙游县| 宜章县| 格尔木市| 即墨市| 泸西县| 平远县| 屯留县| 涿州市| 鹿泉市| 额济纳旗| 龙里县| 天津市| 西青区| 同德县| 巴南区| 衢州市| 二手房| 偃师市| 明水县| 内丘县| 淳安县| 临海市| 灵川县|