scrollview 사용자 정의 페이지Enable

3820 단어 iOS코드
#pragma mark 
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    _startY = scrollView.contentOffset.y;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (decelerate) return;
    [selfdealPageEnableWithScrollView:scrollView];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [selfdealPageEnableWithScrollView:scrollView];
}
#pragma mark   scrollView    
- (void)dealPageEnableWithScrollView:(UIScrollView *)scrollView{
    static CGFloat halfH;
    halfH = halfH ? halfH : scrollView.bounds.size.height;
    NSLog(@"-----------------%zi%zi%zi",scrollView.contentOffset.y > (_otherPageStartY - halfH),_startY < scrollView.contentOffset.y,_startY < (_otherPageStartY - halfH));
    NSLog(@"*****************%zi%zi%zi",scrollView.contentOffset.y < _otherPageStartY,_startY > scrollView.contentOffset.y,_startY >= _otherPageStartY);
    if (scrollView.contentOffset.y > (_otherPageStartY - halfH +60) &&
        _startY < scrollView.contentOffset.y &&
        _startY < _otherPageStartY
//        _isSecondPage) {//        BOOL             ,        
        [UIViewanimateWithDuration:0.5animations:^{
            [scrollView setContentOffset:CGPointMake(0,_otherPageStartY)];
        } completion:^(BOOL finished) {
            NSLog(@"     ------->%f",scrollView.contentOffset.y);
        }];
    }
    else if (scrollView.contentOffset.y < (_otherPageStartY -30) &&
             _startY > scrollView.contentOffset.y &&
             _startY >= (_otherPageStartY - halfH)
//        !_isSecondPage){
        [UIViewanimateWithDuration:0.5animations:^{
            [scrollView setContentOffset:CGPointZero];
        } completion:^(BOOL finished) {
            NSLog(@"     ------->%f",scrollView.contentOffset.y);
        }];
    }

좋은 웹페이지 즐겨찾기