|
|
@ -155,20 +155,7 @@ class HomeRefreshHeader: MJRefreshStateHeader {
|
|
|
|
return refreshLoadingView
|
|
|
|
return refreshLoadingView
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
let tipsLabel: PaddingLabel = {
|
|
|
|
|
|
|
|
let tipsLabel = PaddingLabel.init(padding: .init(top: 5, left: 15, bottom: 5, right: 15), frame: .zero)
|
|
|
|
|
|
|
|
tipsLabel.font = UIFont.systemFont(ofSize: 15)
|
|
|
|
|
|
|
|
tipsLabel.textColor = .tertiaryText()
|
|
|
|
|
|
|
|
tipsLabel.text = "已刷新完成"
|
|
|
|
|
|
|
|
tipsLabel.backgroundColor = .red
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tipsLabel.textColor = .primaryText()
|
|
|
|
|
|
|
|
tipsLabel.alpha = 1
|
|
|
|
|
|
|
|
tipsLabel.isHidden = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tipsLabel
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
override init(frame: CGRect) {
|
|
|
@ -177,7 +164,6 @@ class HomeRefreshHeader: MJRefreshStateHeader {
|
|
|
|
stateLabel?.isHidden = true
|
|
|
|
stateLabel?.isHidden = true
|
|
|
|
|
|
|
|
|
|
|
|
addSubview(self.gifLoadingView)
|
|
|
|
addSubview(self.gifLoadingView)
|
|
|
|
addSubview(tipsLabel)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
@ -214,7 +200,7 @@ class HomeRefreshHeader: MJRefreshStateHeader {
|
|
|
|
override func placeSubviews() {
|
|
|
|
override func placeSubviews() {
|
|
|
|
super.placeSubviews()
|
|
|
|
super.placeSubviews()
|
|
|
|
|
|
|
|
|
|
|
|
backgroundColor = .red
|
|
|
|
|
|
|
|
gifLoadingView.backgroundColor = .blue
|
|
|
|
gifLoadingView.backgroundColor = .blue
|
|
|
|
|
|
|
|
|
|
|
|
gifLoadingView.frame = CGRect.init(x: 0, y: 0, width: 60, height: 60)
|
|
|
|
gifLoadingView.frame = CGRect.init(x: 0, y: 0, width: 60, height: 60)
|
|
|
@ -224,12 +210,7 @@ class HomeRefreshHeader: MJRefreshStateHeader {
|
|
|
|
let centerY = mj_h + 18
|
|
|
|
let centerY = mj_h + 18
|
|
|
|
gifLoadingView.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
gifLoadingView.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
|
|
|
|
|
|
|
|
tipsLabel.snp.makeConstraints { make in
|
|
|
|
|
|
|
|
make.centerX.equalTo(gifLoadingView)
|
|
|
|
|
|
|
|
make.centerY.equalTo(gifLoadingView)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// tipsLabel.sizeToFit()
|
|
|
|
// tipsLabel.sizeToFit()
|
|
|
|
// tipsLabel.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override func scrollViewContentOffsetDidChange(_ change: [AnyHashable : Any]?) {
|
|
|
|
override func scrollViewContentOffsetDidChange(_ change: [AnyHashable : Any]?) {
|
|
|
@ -280,6 +261,20 @@ class RefreshHeader: MJRefreshStateHeader {
|
|
|
|
return refreshLoadingView
|
|
|
|
return refreshLoadingView
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let tipsLabel: PaddingLabel = {
|
|
|
|
|
|
|
|
let tipsLabel = PaddingLabel.init(padding: .init(top: 5, left: 15, bottom: 5, right: 15), frame: .zero)
|
|
|
|
|
|
|
|
tipsLabel.font = UIFont.systemFont(ofSize: 15)
|
|
|
|
|
|
|
|
tipsLabel.textColor = .tertiaryText()
|
|
|
|
|
|
|
|
tipsLabel.text = "已刷新完成"
|
|
|
|
|
|
|
|
// tipsLabel.backgroundColor = .red
|
|
|
|
|
|
|
|
tipsLabel.textAlignment = .center
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tipsLabel.textColor = .primaryText()
|
|
|
|
|
|
|
|
tipsLabel.isHidden = true
|
|
|
|
|
|
|
|
tipsLabel.alpha = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tipsLabel
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
super.init(frame: frame)
|
|
|
@ -287,6 +282,8 @@ class RefreshHeader: MJRefreshStateHeader {
|
|
|
|
stateLabel?.isHidden = true
|
|
|
|
stateLabel?.isHidden = true
|
|
|
|
|
|
|
|
|
|
|
|
addSubview(self.gifLoadingView)
|
|
|
|
addSubview(self.gifLoadingView)
|
|
|
|
|
|
|
|
addSubview(self.tipsLabel)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
@ -331,6 +328,9 @@ class RefreshHeader: MJRefreshStateHeader {
|
|
|
|
let centerY = mj_h * 0.5
|
|
|
|
let centerY = mj_h * 0.5
|
|
|
|
gifLoadingView.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
gifLoadingView.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tipsLabel.frame = CGRect.init(x: 0, y: 0, width: mj_w, height: 60)
|
|
|
|
|
|
|
|
tipsLabel.center = CGPoint(x: centerX, y: centerY)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func calculateOpacity(withOffset offset: CGFloat) -> CGFloat {
|
|
|
|
func calculateOpacity(withOffset offset: CGFloat) -> CGFloat {
|
|
|
@ -401,5 +401,27 @@ class RefreshHeader: MJRefreshStateHeader {
|
|
|
|
// Implement the initialization state logic here
|
|
|
|
// Implement the initialization state logic here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func endRefreshingWithMessage(_ message: String) {
|
|
|
|
|
|
|
|
tipsLabel.isHidden = false
|
|
|
|
|
|
|
|
tipsLabel.text = message
|
|
|
|
|
|
|
|
gifLoadingView.isHidden = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIView.animate(withDuration: 0.3) {
|
|
|
|
|
|
|
|
self.tipsLabel.alpha = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func hidenTipsLabel() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIView.animate(withDuration: 1) {
|
|
|
|
|
|
|
|
self.tipsLabel.alpha = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} completion: { _ in
|
|
|
|
|
|
|
|
self.gifLoadingView.isHidden = false
|
|
|
|
|
|
|
|
self.tipsLabel.isHidden = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|