MoviaBox/ShortPlay/Base/View/SPTableView.swift
2025-04-14 16:32:48 +08:00

52 lines
1.4 KiB
Swift

//
// SPTableView.swift
// ShortPlay
//
// Created by on 2025/4/14.
//
import UIKit
class SPTableView: UITableView {
var insetGroupedMargins: CGFloat = 12
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)
// separatorColor = .lineColor()
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 #available(iOS 13.0, *) {
if self.style == .insetGrouped {
margins.left = self.safeAreaInsets.left + insetGroupedMargins
margins.right = self.safeAreaInsets.right + insetGroupedMargins
}
}
return margins
}
}
}