import UIKit let ScreenWidth = UIScreen.main.bounds.size.width let ScreenHeight = UIScreen.main.bounds.size.height let FooterInSectionColor = uicolor. init(red: 240/255.0, green: 241/255.0, Blue: 244/255.0, alpha: 1) Class ViewController: UIViewController {private lazy var dataSource: Array = {return [[["title": "smart hardware "]], [["title":" feature alarm "], ["title": "feature alarm "], ["title":" feature alarm "] : "Timing closure"]], [[" title ":" accounts and security "]], [[" title ":" push Settings "], [" title ":" listen to preferences "], [" title ":" privacy Settings "]], [[" title ": "Breakpoint continue listening to"], [" title ":" 2 g / 3 g / 4 g play and download "], [" title ":" download sound "], [" title ":" clear footprint "]], [[" title ":" features "], [" title ": ]]}() private var TableView private var TableView: UITableView = { let tableView = UITableView.init(frame:CGRect(x:0, y:0, width:ScreenWidth, height:ScreenHeight), style: UITableView.Style.plain) tableView.delegate = self tableView.dataSource = self tableView.backgroundColor = footerInSectionColor tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") return tableView} () override func viewDidLoad () {. Super viewDidLoad () the self. The navigationItem. Title = "Settings" self.view.addSubview(self.tableView) } } extension ViewController : UITableViewDelegate, UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return dataSource.count } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dataSource[section].count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.selectionStyle = .none let sectionArray = dataSource[indexPath.section] let dict: [String: String] = sectionArray[indexPath.row] cell.textLabel?.text = dict["title"] if indexPath.section == 3 && indexPath.row ==  1 { let cellSwitch = UISwitch.init() cell.accessoryView = cellSwitch }else { cell.accessoryType = .disclosureIndicator } return cell } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 10 } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { let footerView = UIView() footerView.backgroundColor = footerInSectionColor return footerView } }Copy the code