UITableViewHeaderFooterView: Unable to change background color

前端 未结 20 2252
误落风尘
误落风尘 2020-12-23 08:38

I\'m trying to change the background color of UITableViewHeaderFooterView. Although the view is appearing, the background color remains the default color. I\'m getting a log

20条回答
  •  悲哀的现实
    2020-12-23 09:23

    If you are customising a section header cell with Storyboard/Nib, then make sure the background color is default for the "Table Section Header" view.

    And if you subclass UITableViewHeaderFooterView, and using nib, then what you have to do is to create a IBOutlet for the content view, and name it eg. containerView. This is not to be confused with contentView, which is parent of this container view.

    With that setup, you change the background color of containerView instead.

提交回复
热议问题