本内容是基于swift5.0版本的UITableView的实现,话不都说上代码
//
// ViewController.swift
// textmodel
//
// Created by 袁灿 on 2021/7/30.
//
import UIKit
let LBFMScreenWidth = UIScreen.main.bounds.size.width
let LBFMScreenHeight = UIScreen.main.bounds.size.height
class ViewController: UIViewController {
private let ViewCellID = "ViewCell"
// 初始数据
private lazy var datalist: [String] = {
return ["标题1","标题2","标题3","标题4","标题5","标题6",]
}()
// 创建tableView
private lazy var tableView: UITableView = {
let tableView = UITableView.init(frame: CGRect(x: 0, y: 0, width: LBFMScreenWidth, height: LBFMScreenHeight), style: UITableView.Style.plain)
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.white
// 注册cell
tableView.register(ViewCell.self, forCellReuseIdentifier: V