汽车公司可能用到的知识点iOS接下来要研究的知识点需要马上研究的

判断 TableView 滚动方向

2015-06-20  本文已影响0人  __将离

  在 iOS 中,我们往往会根据 tableview 的滚动方向来影藏或者显示放在顶部或者地步的view。

  因为 tableview 继承于 scrollview,所以只需要在代理方法里判断一下偏移量的值就可以了。

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];

if (translation.y>0) {

[UIView animateWithDuration:0.3 animations:^{

self.topView.frame = CGRectMake(0, 0, 320, 64);

self.footView.frame = CGRectMake(0, 568 - 40, 320, 40);

}];

}else if(translation.y<0){

[UIView animateWithDuration:0.3 animations:^{

self.topView.frame = CGRectMake(0, -64, 320, 64);

self.footView.frame = CGRectMake(0, 568, 320, 40);

}];

}

}

上一篇 下一篇

猜你喜欢

热点阅读