1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // PublishMusicView.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/6/23.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- // 音乐选择のView
- import UIKit
- class PublishMusicView: BaseView {
-
- typealias DismissViewClosure = () -> Void
- var dismissViewClosure : DismissViewClosure?
-
- override func setupViews() {
- self.backgroundColor = UIColor.clear
-
- // 添加毛玻璃效果,需使用frame设置位置
- let blurEffect = UIBlurEffect(style: .dark)
- let blurEffectView = UIVisualEffectView(effect: blurEffect)
- blurEffectView.frame = CGRect(x: CGFloat(0), y: kNavBarTotalHeight, width: kScreenWidth, height: kScreenHeight-kNavBarTotalHeight)
- addSubview(blurEffectView)
-
- addSubview(headerView)
- addSubview(tableView)
- }
-
- override func setupLayouts() {
- headerView.snp.makeConstraints { (make) in
- make.top.equalToSuperview().offset(kNavBarTotalHeight)
- make.left.right.equalTo(0)
- make.height.equalTo(48)
- }
- tableView.snp.makeConstraints { (make) in
- make.top.equalTo(headerView.snp_bottom)
- make.left.right.bottom.equalTo(0)
- }
- }
-
- lazy var headerView: PublishMusicHeader = {
- let headerView = PublishMusicHeader()
- headerView.backgroundColor = UIColor.clear
- headerView.dismissClosure = {
- [weak self] in
- if let dismissViewClosure = self?.dismissViewClosure {
- dismissViewClosure()
- }
- }
- return headerView
- }()
-
- lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
- tableView.separatorStyle = .none
- tableView.backgroundColor = UIColor.clear
- tableView.dataSource = self
- tableView.delegate = self
- tableView.estimatedRowHeight = 50
- tableView.estimatedSectionFooterHeight = 0.000001
- tableView.estimatedSectionHeaderHeight = 0.000001
- return tableView
- }()
- }
- extension PublishMusicView: UITableViewDataSource, UITableViewDelegate {
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return 5
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = PublishMusicItemCell.cellWith(tableView: tableView, indexPath: indexPath)
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- print("点击了----\(indexPath.row)")
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 50
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 0
- }
-
- }
|