728x90
반응형
주의 : 코드만 있음!!
import UIKit
enum SettingOptions: Int, CaseIterable {
case total, personal, other
var section: String {
switch self {
case .total: return "전체 설정"
case .personal: return "개인 설정"
case .other: return "기타"
}
}
var rowTitle: [String] {
switch self {
case .total: return ["공지사항", "실험실", "버전 정보"]
case .personal: return ["개인/보안", "알림", "채팅", "멀티프로필"]
case .other: return ["고객센터/도움말"]
}
}
}
class AssignmentTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSections(in tableView: UITableView) -> Int {
return SettingOptions.allCases.count
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return SettingOptions.allCases[section].section
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return SettingOptions.allCases[section].rowTitle.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "assignmentCell")!
cell.textLabel?.textColor = .lightGray
cell.textLabel?.font = .boldSystemFont(ofSize: 12)
cell.textLabel?.text = SettingOptions.allCases[indexPath.section].rowTitle[indexPath.row]
return cell
}
}
728x90
반응형
'⭐️ 개발 > iOS & Swift' 카테고리의 다른 글
[Swift] 타입 프로퍼티 왜 씀? (0) | 2022.07.21 |
---|---|
[iOS] cell shadow + cornerRadius 같이 주는 방법 (0) | 2022.07.21 |
[iOS] for - in / forEach 동작구조? (0) | 2022.07.19 |
[iOS] Formatted API in iOS15 (0) | 2022.07.13 |
[iOS] Copy items if needed, Move to Trash (0) | 2022.07.13 |