//
|
// CourseSubTypeView.swift
|
// WanPai
|
//
|
// Created by 杨锴 on 2023/6/9.
|
//
|
|
import UIKit
|
import JQTools
|
|
class CourseSubTypeView: UIView,JQNibView{
|
|
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var cons_tableHeight: NSLayoutConstraint!
|
private var closeClouse:(()->Void)?
|
private var clouse:((String)->Void)?
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.register(UINib(nibName: "Common_1_TCell", bundle: nil), forCellReuseIdentifier: "_Common_1_TCell")
|
alpha = 0
|
cons_tableHeight.constant = 0
|
layoutIfNeeded()
|
}
|
|
static func show(inView:UIView,afterView:UIView,items:[String],clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void){
|
let subTypeView = CourseSubTypeView.jq_loadNibView()
|
subTypeView.closeClouse = closeClouse
|
subTypeView.clouse = clouse
|
inView.addSubview(subTypeView)
|
subTypeView.snp.makeConstraints { make in
|
make.top.equalTo(afterView.snp.bottom)
|
make.left.right.bottom.equalToSuperview()
|
}
|
|
UIView.animate(withDuration: 0.2) {
|
subTypeView.alpha = 1
|
} completion: { _ in
|
subTypeView.cons_tableHeight.constant = 220
|
UIView.animate(withDuration: 0.2) {
|
subTypeView.layoutIfNeeded()
|
}
|
}
|
}
|
|
@IBAction func closeAction(_ sender: UIButton) {
|
cons_tableHeight.constant = 0
|
UIView.animate(withDuration: 0.2) {
|
self.alpha = 0
|
self.layoutIfNeeded()
|
} completion: { _ in
|
self.closeClouse?()
|
}
|
}
|
}
|
|
extension CourseSubTypeView:UITableViewDelegate{
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
cons_tableHeight.constant = 0
|
UIView.animate(withDuration: 0.2) {
|
self.alpha = 0
|
self.layoutIfNeeded()
|
} completion: { _ in
|
self.clouse?("")
|
self.closeClouse?()
|
}
|
}
|
}
|
|
extension CourseSubTypeView:UITableViewDataSource{
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_Common_1_TCell") as! Common_1_TCell
|
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return 10
|
}
|
|
|
}
|