Is it possible to disable floating headers in UITableView with UITableViewStylePlain?

前端 未结 29 1106
走了就别回头了
走了就别回头了 2020-11-29 15:02

I\'m using a UITableView to layout content \'pages\'. I\'m using the headers of the table view to layout certain images etc. and I\'d prefer it if they didn\'t

29条回答
  •  囚心锁ツ
    2020-11-29 15:18

    The interesting thing about UITableViewStyleGrouped is that the tableView adds the style to the cells and not to the TableView.

    The style is added as backgroundView to the cells as a class called UIGroupTableViewCellBackground which handles drawing different background according to the position of the cell in the section.

    So a very simple solution will be to use UITableViewStyleGrouped, set the backgroundColor of the table to clearColor, and simply replace the backgroundView of the cell in cellForRow:

    cell.backgroundView = [[[UIView alloc] initWithFrame:cell.bounds] autorelease];
    

提交回复
热议问题