Commit 0afb9c57 authored by David黄金龙's avatar David黄金龙

Merge branch 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into youhua-dev

* 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  //  文件清单
parents a293c182 3ec246e7
......@@ -106,19 +106,12 @@ class YHMyFileListViewController: YHBaseViewController {
}()
lazy var segmentView:YHSegmentView = {
let view = YHSegmentView(frame: CGRect(x: 16, y: 0, width: KScreenWidth-16.0*2, height: 46))
let view = YHSegmentView(frame: CGRect(x: 0, y: 0, width: KScreenWidth-16.0*2, height: 46))
view.items = titles
view.selectBlock = {
[weak self] index in
guard let self = self else { return }
if 0 <= index && index < self.items.count {
self.tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: {
let currentOffsetY = self.tableView.contentOffset.y
printLog("adfa:\(currentOffsetY)")
self.tableView.setContentOffset(CGPointMake(0, currentOffsetY-k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight), animated: true)
})
}
self.scrollToSection(index)
}
return view
}()
......@@ -130,19 +123,19 @@ class YHMyFileListViewController: YHBaseViewController {
view.selectBlock = {
[weak self] index in
guard let self = self else { return }
if 0 <= index && index < self.items.count {
self.tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: {
let currentOffsetY = self.tableView.contentOffset.y
printLog("adfa:\(currentOffsetY)")
let sectionHeigt = self.tableView(self.tableView, heightForHeaderInSection: index)
self.tableView.setContentOffset(CGPointMake(0, currentOffsetY-k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight), animated: true)
})
}
self.scrollToSection(index)
}
return view
}()
func scrollToSection(_ section:Int) {
if 0 <= section && section < self.items.count {
var sectionRect = self.tableView.rectForHeader(inSection: section)
sectionRect.origin.y = sectionRect.origin.y-k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight
self.tableView.setContentOffset(CGPointMake(0, sectionRect.origin.y+4), animated: true)
}
}
lazy var titles = ["主申请人", "配偶", "子女"]
override func viewDidLoad() {
......@@ -249,10 +242,35 @@ extension YHMyFileListViewController : UITableViewDelegate, UITableViewDataSourc
func scrollViewDidScroll(_ scrollView: UIScrollView) {
printLog("offset: \(scrollView.contentOffset.y)")
let gap = -k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight
let gap = self.consentInsetTop-k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight
self.navStatusBar.backgroundColor = scrollView.contentOffset.y > gap ? UIColor.white : UIColor.clear
self.topSegmentView.backgroundColor = scrollView.contentOffset.y > gap ? UIColor.white : UIColor.clear
self.topSegmentView.isHidden = scrollView.contentOffset.y < gap
// 滚动到哪个section 对应的segment要显示相应的index
if items.count > 0 {
var arr:[Double] = []
for index in 0..<items.count {
var rect = self.tableView.rectForHeader(inSection: index)
let y = rect.origin.y-k_Height_NavigationtBarAndStatuBar-self.topSegmentHeight
arr.append(y)
for (index, offY) in arr.reversed().enumerated() {
if index == arr.count-1 {
self.topSegmentView.updateSelectIndex(arr.count-index-1)
self.segmentView.updateSelectIndex(arr.count-index-1)
break
} else {
if scrollView.contentOffset.y >= offY+2 {
self.topSegmentView.updateSelectIndex(arr.count-index-1)
self.segmentView.updateSelectIndex(arr.count-index-1)
break
}
}
}
}
}
}
}
......
......@@ -97,13 +97,17 @@ class YHSegmentView: UIView {
@objc func didClickItem(_ gesture:UIGestureRecognizer) {
if let view = gesture.view as? YHSegmentItemView {
let selectTag = view.tag
self.selectBlock?(selectTag-self.itemBaseTag)
for subView in self.subviews {
if subView is YHSegmentItemView {
let subItemView = subView as! YHSegmentItemView
subItemView.isSelect = subItemView.tag == selectTag
}
let selectIndex = view.tag-self.itemBaseTag
self.selectBlock?(selectIndex)
updateSelectIndex(selectIndex)
}
}
func updateSelectIndex(_ index: Int) {
for subView in self.subviews {
if subView is YHSegmentItemView {
let subItemView = subView as! YHSegmentItemView
subItemView.isSelect = subItemView.tag == index+self.itemBaseTag
}
}
}
......
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