Created
March 8, 2021 02:41
-
-
Save KrauserHuang/3f0593bb4a9a96d38e4e894c08822b86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
// 取讀螢幕尺寸 | |
let fullScreenSize = UIScreen.main.bounds.size | |
// 設定UITableView,原點/尺寸,另外style可設定是否tableView是一大串row或是有section分隔 | |
let myTableView = UITableView(frame: CGRect(x: 0, y: 20, width: fullScreenSize.width, height: fullScreenSize.height - 20), style: .grouped) | |
// 註冊cell | |
myTableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") | |
// 設定Delegate/DataSource對象(也就是這一個ViewController本身) | |
myTableView.delegate = self | |
myTableView.dataSource = self | |
// 設定section的分隔線樣式 | |
myTableView.separatorStyle = .singleLine | |
// 分隔線間距 | |
myTableView.separatorInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) | |
// 是否可以單選/多選cell | |
myTableView.allowsSelection = true | |
myTableView.allowsMultipleSelection = false | |
// 加到畫面 | |
view.addSubview(myTableView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment