swift - iOS 15以后设置 tableview 的 style: .plain 后,tableHeaderView 下边会多出大约20像素

如图所示:


多出大约20像素
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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容