在做朋友圈功能时,遇到这样的一个需求,需要用到 UITableView的悬停效果但是样式不能一样,怎么办呢?
sectionHeader 中动态改变Header 的内容,
funcscrollViewDidScroll(_scrollView:UIScrollView) {
letpoint = scrollView.panGestureRecognizer.velocity(in:self.view)
let offsetY = scrollView.contentOffset.y;
iflet header =self.tempSectionView{
letorigin = header.superview?.convert(header.origin, to:UIApplication.shared.keyWindow)
letrealHeight = origin?.y??0- offsetY
varbool =true
if(point.y>0){
//向上滚动
bool =true
}else{
// 向下滚动
bool =false
}
if(realHeight <80 && realHeight >0){
// 向下滑
if!bool{
if self.currSection< (self.m_yearData.count-1) {
self.currSection+=1
}
self.m_YearLabel.text = self.m_yearData[self.currSection]
}else{
// 向上滑
ifself.currSection!=0{
self.currSection-=1
}
self.m_YearLabel.text = self.m_yearData[self.currSection]
}
}else{
}
}
网友评论