国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

改變iOS應用中UITableView的背景顏色與背景圖片的方法

2019-10-21 18:55:20
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了改變iOS應用中UITableView的背景顏色與背景圖片的方法,將UITableView的header、footer設成clearColor時要注意實際效果是否真的變透明,需要的朋友可以參考下
 

改變UITableView的header、footer背景顏色

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

對于iOS 6及以后的系統,實現這個新的delegate函數即可:

復制代碼代碼如下:

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

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

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

修改tableView的背景圖片

 

修改UITableView的背景圖片

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

復制代碼代碼如下:

// viewDidLoad

 

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

// cellForRowAtIndexPath

cell.backgroundColor = [UIColor clearColor];


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

 

2.正常的背景圖片。

復制代碼代碼如下:

// viewDidLoad

 

self.tableView.backgroundColor= [UIColor clearColor];

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

self.tableView.backgroundView = imageView;

// cellForRowAtIndexPath

cell.backgroundColor = [UIColor clearColor];


這種情況下背景圖片不會動,即無論多少行看到的都是同樣的背景。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 康乐县| 乌苏市| 柞水县| 八宿县| 文登市| 赤峰市| 甘孜县| 贵港市| 黑河市| 水城县| 盐边县| 东明县| 江达县| 万安县| 赣榆县| 潮安县| 当雄县| 界首市| 新民市| 灌南县| 化德县| 建宁县| 南京市| 新丰县| 连城县| 阳原县| 万源市| 邵武市| 江油市| 清新县| 永安市| 玉田县| 西充县| 襄樊市| 海门市| 高密市| 宁陵县| 加查县| 察哈| 汝城县| 青州市|