簡體   English   中英

更改headerView的backgroundColor

[英]Change the backgroundColor of the headerView

我正在嘗試在Grouped tabledView中更改headerView顏色。 但是,似乎在第二個標頭中有一個奇怪的行為。 它沒有填充完整的標頭? 怎么會這樣

override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    var headerView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, 44))
    headerView.backgroundColor = UIColor.redColor()





    return headerView
}

override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 44
}

在此處輸入圖片說明

分組的表視圖具有表節頁腳。 您會看到該部分的頁腳為灰色。 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section方法中,返回0或CGFLOAT_MIN以隱藏頁腳。 我認為在CGFLOAT_MIN情況下0無效,您必須執行CGFLOAT_MIN但如果0 CGFLOAT_MIN ,請嘗試兩者。

下面是快速示例override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return CGFLOAT_MIN; } override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return CGFLOAT_MIN; }

我認為您誤解了第一部分的頁腳可能是第二部分的頁眉的頂部。 如果仔細觀察,您會發現紅色區域實際上是相同的高度。 有兩件事要檢查。 首先,查看表格頁腳的高度設置為-可能不為零。 您可以在界面構建器中更改它。 其次,嘗試將表格視圖更改為常規視圖而不是分組視圖,看看是否有任何改變。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM