我想添加填充到此自定义标题视图(图像)。UITableview添加填充到自定义部分标题imageview
该表是static content cells
,我只是在第一部分添加图像。
我试图按照this链接,但不成功。
我想在标题视图中添加一些顶部和底部填充。
我想这没有运气:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
var header = tableView.tableHeaderView
let image = UIImage(named: "Placeholder") // is 121x121
let imageView = UIImageView(frame: CGRect(x: 0, y: 20, width: tableView.frame.width, height: tableView.sectionHeaderHeight))
imageView.image = image
imageView.contentMode = .scaleAspectFit
header = imageView
return header
}
return nil
}
我也定义页眉高度委托:
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return 125.0
}
return 44.0
}
结果是没有填充相同。
任何帮助,将不胜感激
我也曾尝试到的ImageView添加到头部子视图导致整个图像消失英寸
如果*表是'静态内容cells' *,你能添加它作为表本身的头?或者您是否需要图像作为第一部分的标题? – DonMag