3 回答

TA貢獻1780條經驗 獲得超1個贊
您可以在Interface Builder中輕松完成此操作。只需使用表創建視圖,然后將另一個視圖放到表上。這將成為表標題視圖。將標簽和圖像添加到該視圖。有關視圖層次結構,請參見下面的圖片。

TA貢獻1811條經驗 獲得超4個贊
在Swift中:
override func viewDidLoad() {
super.viewDidLoad()
// We set the table view header.
let cellTableViewHeader = tableView.dequeueReusableCellWithIdentifier(TableViewController.tableViewHeaderCustomCellIdentifier) as! UITableViewCell
cellTableViewHeader.frame = CGRectMake(0, 0, self.tableView.bounds.width, self.heightCache[TableViewController.tableViewHeaderCustomCellIdentifier]!)
self.tableView.tableHeaderView = cellTableViewHeader
// We set the table view footer, just know that it will also remove extra cells from tableview.
let cellTableViewFooter = tableView.dequeueReusableCellWithIdentifier(TableViewController.tableViewFooterCustomCellIdentifier) as! UITableViewCell
cellTableViewFooter.frame = CGRectMake(0, 0, self.tableView.bounds.width, self.heightCache[TableViewController.tableViewFooterCustomCellIdentifier]!)
self.tableView.tableFooterView = cellTableViewFooter
}
- 3 回答
- 0 關注
- 1304 瀏覽
添加回答
舉報