Home > Back-end >  iOS 15 - UItableView top padding issue
iOS 15 - UItableView top padding issue

Time:09-24

I updated my iPhone to iOS 15 and Xcode to 13 version and now my app have a weird padding on top in all screens that has a tableView. enter image description here

How can I solve this problem?

CodePudding user response:

After a lot of research, I founded the answer in Apple developer documentation: https://developer.apple.com/documentation/uikit/uitableview/3750914-sectionheadertoppadding?language=objc

So, to solve this problem I added this code in all screen that I was using UITableView:

if #available(iOS 15.0, *) {
   tableView.sectionHeaderTopPadding = .zero
}

With this code the gap goes away.

CodePudding user response:

If you want to remove this top padding in all views, you can call this code in AppDelegate:

if #available(iOS 15.0, *) {
    UITableView.appearance().sectionHeaderTopPadding = .zero
}
  • Related