50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
//
|
|
// BRTableView.swift
|
|
// BeeReel
|
|
//
|
|
// Created by 湖南秦九 on 2025/6/27.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class BRTableView: UITableView {
|
|
|
|
var insetGroupedMargins: CGFloat = 15
|
|
|
|
override init(frame: CGRect, style: UITableView.Style) {
|
|
super.init(frame: frame, style: style)
|
|
separatorColor = .colorFFFFFF(alpha: 0.1)
|
|
separatorInset = .init(top: 0, left: 16, bottom: 0, right: 16)
|
|
self.backgroundColor = .clear
|
|
self.contentInsetAdjustmentBehavior = .never
|
|
|
|
if style == .insetGrouped {
|
|
sectionFooterHeight = 12
|
|
sectionHeaderHeight = 0.1
|
|
} else if style == .plain {
|
|
if #available(iOS 15.0, *) {
|
|
sectionHeaderTopPadding = 0
|
|
}
|
|
}
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
///修改 insetGrouped 的边距 参考https://github.com/QMUI/QMUIDemo_iOS/blob/master/QMUI/QMUIKit/UIKitExtensions/UITableView%2BQMUI.m
|
|
override var layoutMargins: UIEdgeInsets {
|
|
set {
|
|
super.layoutMargins = newValue
|
|
}
|
|
get {
|
|
var margins = super.layoutMargins
|
|
if self.style == .insetGrouped {
|
|
margins.left = self.safeAreaInsets.left + insetGroupedMargins
|
|
margins.right = self.safeAreaInsets.right + insetGroupedMargins
|
|
}
|
|
return margins
|
|
}
|
|
}
|
|
}
|