PublishMusicView.swift 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // PublishMusicView.swift
  3. // RainbowPlanet
  4. //
  5. // Created by Christopher on 2019/6/23.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. // 音乐选择のView
  8. import UIKit
  9. class PublishMusicView: BaseView {
  10. typealias DismissViewClosure = () -> Void
  11. var dismissViewClosure : DismissViewClosure?
  12. override func setupViews() {
  13. self.backgroundColor = UIColor.clear
  14. // 添加毛玻璃效果,需使用frame设置位置
  15. let blurEffect = UIBlurEffect(style: .dark)
  16. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  17. blurEffectView.frame = CGRect(x: CGFloat(0), y: kNavBarTotalHeight, width: kScreenWidth, height: kScreenHeight-kNavBarTotalHeight)
  18. addSubview(blurEffectView)
  19. addSubview(headerView)
  20. addSubview(tableView)
  21. }
  22. override func setupLayouts() {
  23. headerView.snp.makeConstraints { (make) in
  24. make.top.equalToSuperview().offset(kNavBarTotalHeight)
  25. make.left.right.equalTo(0)
  26. make.height.equalTo(48)
  27. }
  28. tableView.snp.makeConstraints { (make) in
  29. make.top.equalTo(headerView.snp_bottom)
  30. make.left.right.bottom.equalTo(0)
  31. }
  32. }
  33. lazy var headerView: PublishMusicHeader = {
  34. let headerView = PublishMusicHeader()
  35. headerView.backgroundColor = UIColor.clear
  36. headerView.dismissClosure = {
  37. [weak self] in
  38. if let dismissViewClosure = self?.dismissViewClosure {
  39. dismissViewClosure()
  40. }
  41. }
  42. return headerView
  43. }()
  44. lazy var tableView: UITableView = {
  45. let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
  46. tableView.separatorStyle = .none
  47. tableView.backgroundColor = UIColor.clear
  48. tableView.dataSource = self
  49. tableView.delegate = self
  50. tableView.estimatedRowHeight = 50
  51. tableView.estimatedSectionFooterHeight = 0.000001
  52. tableView.estimatedSectionHeaderHeight = 0.000001
  53. return tableView
  54. }()
  55. }
  56. extension PublishMusicView: UITableViewDataSource, UITableViewDelegate {
  57. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  58. return 5
  59. }
  60. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  61. let cell = PublishMusicItemCell.cellWith(tableView: tableView, indexPath: indexPath)
  62. return cell
  63. }
  64. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  65. print("点击了----\(indexPath.row)")
  66. }
  67. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  68. return 50
  69. }
  70. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  71. return 0
  72. }
  73. }