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

前端 未结 30 3111
隐瞒了意图╮
隐瞒了意图╮ 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 12:59

    This is the solution for iOS 10 using Swift 3:

    You can get rid of top and bottom paddings by implementing the following methods from the UITableViewDelegate.

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

提交回复
热议问题