PushNotificationSettingsViewController.swift 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // PushNotificationSettingsViewController.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/9/19.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. class PushNotificationSettingsViewController: BaseViewController {
  10. let sections = [["接收推送通知"],
  11. ["系统通知","评论和回复","赞与互动","关注"]]
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. setupViews()
  15. setupLayouts()
  16. // Do any additional setup after loading the view.
  17. }
  18. override func setupViews() {
  19. navigationBar.title = "推送通知设置"
  20. view.addSubview(tableView)
  21. }
  22. override func setupLayouts() {
  23. tableView.snp.makeConstraints { (make) in
  24. make.right.left.bottom.equalToSuperview()
  25. make.top.equalTo(kNavBarTotalHeight)
  26. }
  27. }
  28. private lazy var tableView: UITableView = {
  29. let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
  30. tableView.backgroundColor = kf7f8faColor
  31. tableView.delegate = self
  32. tableView.dataSource = self
  33. tableView.rowHeight = 48
  34. tableView.separatorStyle = .none
  35. return tableView
  36. }()
  37. }
  38. extension PushNotificationSettingsViewController : UITableViewDelegate,UITableViewDataSource {
  39. func numberOfSections(in tableView: UITableView) -> Int {
  40. return sections.count
  41. }
  42. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  43. return sections[section].count
  44. }
  45. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  46. let cell = PushNotificationSettingsTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
  47. cell.title = sections[indexPath.section][indexPath.row]
  48. return cell
  49. }
  50. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  51. }
  52. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  53. switch section {
  54. case 1:
  55. let headerView = PushNotificationSettingsOneSectionHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 40))
  56. return headerView
  57. default:
  58. return nil
  59. }
  60. }
  61. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  62. switch section {
  63. case 0:
  64. return 10
  65. default:
  66. return 40
  67. }
  68. }
  69. func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
  70. return nil
  71. }
  72. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  73. return 0.0000001
  74. }
  75. }