Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

前端 未结 30 3137
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 12:47

Starting in iOS7, there is additional space at the top of my UITableView\'s which have a style UITableViewStyleGrouped.

Here is an example:<

30条回答
  •  误落风尘
    2020-11-22 13:21

    Swift 4 code: For tableview with no section headers you can add this code:

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return CGFloat.leastNormalMagnitude
    }
    

    and you will get the header spacing to 0.

    If you want a header of your specific height pass that value:

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return header_height
    }
    

    and the view from viewForHeaderinSection delegate.

提交回复
热议问题