《笔记》自定义UITableView的headerView设置背景色无效的解决方案

自定义headerView设置背景色无效,提示:

Changing the background color on a UITableViewHeaderFooterView loaded from a xib says to use contentView.backgroundColor instead

但是调用 contentView.background也无效,因为自定义的headerView并没有这个contentView,也就是说contentView = nil

解决方法就是在自定义headerView的最下层,放一个bgView充当背景色,或者放一张图片在最下边。

显示 Gitment 评论