Swift-Code Snippet

81 阅读1分钟

mark

image.png

image.png

image.png

pmark
// MARK: -

UITableView

ptableview
lazy var mainView: UITableView = {
    let view = UITableView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight - kTopHeight), style: .plain)
    view.delegate = self
    view.dataSource = self
    view.tableHeaderView = UIView()
    view.tableFooterView = UIView()
    view.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    view.separatorStyle = .none
    view.backgroundColor = .white
    view.rowHeight = 44
    view.showsHorizontalScrollIndicator = false
    view.showsVerticalScrollIndicator = false
    if #available(iOS 11.0, *) {
        // 底部空余安全距离
        view.contentInsetAdjustmentBehavior = .never
        view.estimatedRowHeight = 0
        view.estimatedSectionHeaderHeight = 0
        view.estimatedSectionFooterHeight = 0
    } else {
        self.automaticallyAdjustsScrollViewInsets = false
    }
    if #available(iOS 15.0, *) {
        UITableView.appearance().sectionHeaderTopPadding = 0
    }
    return view
}()

required init?

prequiredinit


required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}