判断ScrollView滑动的方向

 
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    //Selected index's color changed.
    static float newx = 0;
    static float oldIx = 0;
    newx= scrollView.contentOffset.x ;
    if (newx != oldx ) {
        //Left-YES,Right-NO
        if (newx > oldx) {
            self.scrollLeftOrRight = NO;
        }else if(newIndex < oldIndex){
            self.scrollLeftOrRight = YES;
        }
        oldx = newx;
    }


你可能感兴趣的:(uiscrollview,滑动方向)