如图所示:
swift
if #available(iOS 15.0, *) {
tableView?.sectionHeaderTopPadding = 0
}
if #available(iOS 15.0, *) {
UITableView.appearance().sectionHeaderTopPadding = 0
}
Object - c
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
}
if (@available(iOS 15.0, *)) {
[UITableView appearance].sectionHeaderTopPadding = 0;
}
修改后
# 在 iOS15 中 UITableView 新增属性和方法:
@property (nonatomic, getter=isPrefetchingEnabled) BOOL prefetchingEnabled
@property (nonatomic) CGFloat fillerRowHeight
@property (nonatomic) CGFloat sectionHeaderTopPadding
@property (nonatomic) BOOL allowsFocus
@property (nonatomic) BOOL allowsFocusDuringEditing
- (void)reconfigureRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
- (BOOL)tableView:(UITableView *)tableView selectionFollowsFocusForRowAtIndexPath:(NSIndexPath *)indexPath