1.1.6首页小调整
This commit is contained in:
parent
188de9fa4f
commit
724e8c2c9f
@ -40,10 +40,19 @@ class MPPositive_HomeViewController: MPPositive_BaseViewController, UIViewContro
|
||||
label.font = UIFont.boldSystemFont(ofSize: 20*width)
|
||||
}
|
||||
label.textColor = .white
|
||||
label.isUserInteractionEnabled = true
|
||||
label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(scrollTopAction(_ :))))
|
||||
return label
|
||||
}()
|
||||
//搜索栏
|
||||
private lazy var searchView = createSearchView()
|
||||
//导航栏内购是否展示
|
||||
private var isBuyShow:Bool = true
|
||||
//最后一次偏移量
|
||||
private var lastContentOffset: CGFloat = 0
|
||||
//是否用户滚动
|
||||
private var isUserDragging:Bool = false
|
||||
|
||||
//tableView
|
||||
private lazy var tableView:UITableView = {
|
||||
let tableView = UITableView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height), style: .plain)
|
||||
@ -263,6 +272,7 @@ class MPPositive_HomeViewController: MPPositive_BaseViewController, UIViewContro
|
||||
pullDownRefreshCountdown()
|
||||
print("下拉刷新超时.")
|
||||
}
|
||||
|
||||
}
|
||||
MPPositive_BrowseLoadViewModel.shared.pullDownRefresh{
|
||||
[weak self] in
|
||||
@ -387,14 +397,60 @@ class MPPositive_HomeViewController: MPPositive_BaseViewController, UIViewContro
|
||||
}
|
||||
}
|
||||
iapVC.modalPresentationStyle = .fullScreen
|
||||
|
||||
present(iapVC, animated: true)
|
||||
}
|
||||
|
||||
@objc private func scrollTopAction(_ sender:UITapGestureRecognizer) {
|
||||
let topOffset = CGPoint(x: 0, y: 0)
|
||||
tableView.setContentOffset(topOffset, animated: true)
|
||||
}
|
||||
}
|
||||
//MARK: - tableView
|
||||
extension MPPositive_HomeViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
// 用户开始拖动scrollView时调用
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
isUserDragging = true
|
||||
lastContentOffset = scrollView.contentOffset.y // 重置 lastContentOffset
|
||||
}
|
||||
|
||||
// 用户停止拖动scrollView时调用
|
||||
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
||||
if !decelerate {
|
||||
isUserDragging = false
|
||||
}
|
||||
}
|
||||
|
||||
// scrollView停止减速时调用
|
||||
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
|
||||
isUserDragging = false
|
||||
}
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
guard isUserDragging, !MPPositive_BrowseLoadViewModel.shared.isRefresh, lastContentOffset >= -(self.tableView.mj_header?.frame.height ?? 0) else { return }
|
||||
let currentOffset = scrollView.contentOffset.y
|
||||
let scrollDiff = currentOffset - lastContentOffset
|
||||
if scrollDiff >= 30 && isBuyShow == true {
|
||||
//收起来
|
||||
adjustHeight(to: 50*width)
|
||||
isBuyShow = false
|
||||
}else if scrollDiff <= -30 && isBuyShow == false {
|
||||
//展示
|
||||
adjustHeight(to: 90*width)
|
||||
isBuyShow = true
|
||||
}
|
||||
// 更新最后的偏移量
|
||||
lastContentOffset = currentOffset
|
||||
}
|
||||
// 调整高度方法
|
||||
func adjustHeight(to height: CGFloat) {
|
||||
UIView.animate(withDuration: 0.3) {[weak self] in
|
||||
guard let self = self else {return}
|
||||
musicLaxLabel.isHidden = !(height > (50*width))
|
||||
vipImageView.isHidden = !(height > (50*width))
|
||||
memuBtn.isHidden = !(height > (50*width))
|
||||
var frame = navView.frame
|
||||
frame.size.height = height
|
||||
self.navView.frame = frame
|
||||
}
|
||||
}
|
||||
func numberOfSections(in tableView: UITableView) -> Int {
|
||||
if MPPositive_BrowseLoadViewModel.shared.libraryList.libraryViewModels.isEmpty {
|
||||
return 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user