Commit 8e5c89a3 authored by David黄金龙's avatar David黄金龙

状态 展示

parent 947b64af
...@@ -7,10 +7,23 @@ ...@@ -7,10 +7,23 @@
// //
import UIKit import UIKit
enum ClickButtonType {
case downAll //全部下载
case cancel //取消
}
class YHMyDocListHeaderView: UIView { class YHMyDocListHeaderView: UIView {
static let viewH : CGFloat = 46.0 static let viewH : CGFloat = 46.0
typealias Block = (ClickButtonType) -> ()
var block: Block?
var curShowType : ClickButtonType? {
didSet {
updataUI()
}
}
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
initView() initView()
...@@ -66,6 +79,7 @@ private extension YHMyDocListHeaderView { ...@@ -66,6 +79,7 @@ private extension YHMyDocListHeaderView {
titleLable.snp.makeConstraints { make in titleLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(kMargin) make.top.equalToSuperview().offset(kMargin)
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.right.equalTo(-80)
make.height.equalTo(26) make.height.equalTo(26)
} }
...@@ -80,9 +94,6 @@ private extension YHMyDocListHeaderView { ...@@ -80,9 +94,6 @@ private extension YHMyDocListHeaderView {
allDownLoadButton.layoutIfNeeded() allDownLoadButton.layoutIfNeeded()
allDownLoadButton.addYinHeGradualLayer() allDownLoadButton.addYinHeGradualLayer()
addSubview(cancelButton) addSubview(cancelButton)
cancelButton.snp.makeConstraints { make in cancelButton.snp.makeConstraints { make in
make.top.equalToSuperview().offset(19) make.top.equalToSuperview().offset(19)
...@@ -91,17 +102,37 @@ private extension YHMyDocListHeaderView { ...@@ -91,17 +102,37 @@ private extension YHMyDocListHeaderView {
make.height.equalTo(24) make.height.equalTo(24)
} }
} }
//点击全部下载按钮 //点击全部下载按钮
@objc func clickAllBtn() { @objc func clickAllBtn() {
hiddenButton(type: .downAll)
block?(.downAll)
} }
//点击取消按钮 //点击取消按钮
@objc func clickCancelBtn() { @objc func clickCancelBtn() {
hiddenButton(type: .cancel)
block?(.cancel)
}
private func hiddenButton(type : ClickButtonType) {
if type == .downAll {
allDownLoadButton.isHidden = true
cancelButton.isHidden = false
} else if type == .cancel {
allDownLoadButton.isHidden = true
cancelButton.isHidden = false
}
}
func updataUI() {
guard let type = curShowType else { return }
if type == .downAll {
hiddenButton(type:.cancel)
} else if type == .cancel {
hiddenButton(type:.downAll)
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment