1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // TSBaseCollectionView.swift
- // Pods
- //
- // Created by 100Years on 2025/6/17.
- //
- open class TSBaseCollectionView: UICollectionView {
- // override var effectiveUserInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
- // return kIsRTL ? .rightToLeft : .leftToRight
- // }
- // MARK: - 初始化
-
- override public init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
- super.init(frame: frame, collectionViewLayout: layout)
- commonInit()
- }
-
- required public init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- // MARK: - 公共配置
-
- private func commonInit() {
- // 通用配置
- backgroundColor = .systemBackground
- keyboardDismissMode = .onDrag
-
-
- if kIsRTL {
- semanticContentAttribute = .forceRightToLeft
- }
-
-
- backgroundColor = .clear
- showsVerticalScrollIndicator = false
- showsHorizontalScrollIndicator = false
- if #available(iOS 11.0, *) {
- contentInsetAdjustmentBehavior = .never
- }
- }
- }
- open class TSBaseCollectionViewFlowLayout: UICollectionViewFlowLayout {
- open override var flipsHorizontallyInOppositeLayoutDirection: Bool {
- return kIsRTL
- }
- }
- open class TSBaseTableView: UITableView {
- // MARK: - 初始化
-
- override public init(frame: CGRect, style: UITableView.Style) {
- super.init(frame: frame, style: style)
- commonInit()
- }
-
- required public init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- // MARK: - 公共配置
- private func commonInit() {
- if #available(iOS 11.0, *) {
- contentInsetAdjustmentBehavior = .never
- }
- if #available(iOS 15.0, *) {
- sectionHeaderTopPadding = 0
- }
- if kIsRTL {
- semanticContentAttribute = .forceRightToLeft
- }
-
- separatorStyle = .none
- backgroundColor = .clear
- estimatedRowHeight = 0
- estimatedSectionHeaderHeight = 0
- estimatedSectionFooterHeight = 0
- showsVerticalScrollIndicator = false
- showsHorizontalScrollIndicator = false
- backgroundColor = .clear
- if tableFooterView == nil {
- tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFLOAT_MIN))
- }
- }
- }
|