UIKit 与图形动画历史技术记录
iOS开发类似折800功能中的一个小Demo
以仿折800的滚动交互为例,记录拖动开始时的 contentOffset,并在滚动回调中比较偏移量来判断方向,附示例工程供对照查看界面的联动效果。
原文未明确署名,作为历史文章归档。
本文目录
"The beginning is the most important part of the work." Plato
–核心代码–
-(void)scrollViewWillBeginDragging:(UIScrollView*)scrollView{
//使用的时候用全局变量
CGFloat lastContentOffset = scrollView.contentOffset.y;
}
-( void )scrollViewDidScroll:( UIScrollView *)scrollView {
if (scrollView.contentOffset.y < lastContentOffset )
{
//向上
NSLog(@"向上");
} else if (scrollView. contentOffset.y >lastContentOffset ){
//向下
NSLog(@"向下");
}
}