Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片快速向下滑动取消的时候,页面会闪烁一下,慢慢滑动没有这个问题. #6

Open
ghost opened this issue Dec 28, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 28, 2017

No description provided.

@ghost ghost changed the title 向下滑动取消的时候,页面偶尔闪烁,几率还是挺大的 图片快速向下滑动取消的时候,页面会闪烁一下,慢慢滑动没有这个问题. Dec 28, 2017
@lvpeng0412
Copy link

lvpeng0412 commented Jan 18, 2018

  • (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    /if (ABS(_scrollView.contentOffset.y) < minPanLength) {
    CGFloat alpha = 1 - ABS(_scrollView.contentOffset.y / (_scrollView.bounds.size.height));
    _collectionView.backgroundColor = [UIColor colorWithWhite:0 alpha:alpha];
    }
    /
    }

  • (void)scrollViewPanMethod:(UIPanGestureRecognizer *)pan {
    if (_scrollView.zoomScale != 1.0f) {return;}
    if (_scrollView.contentOffset.y > 0) {
    _cancleideBlock();
    return;
    }
    //拖拽结束后判断位置
    if (pan.state == UIGestureRecognizerStateEnded) {
    if (ABS(_scrollView.contentOffset.y) < minPanLength) {
    _cancleideBlock();
    [UIView animateWithDuration:0.35 animations:^{
    _## collectionView.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
    _scrollView.contentInset = UIEdgeInsetsZero;
    }];
    } else {
    [UIView animateWithDuration:0.35 animations:^{
    //设置移除动画
    CGRect frame = _imageView.frame;
    frame.origin.y = _scrollView.bounds.size.height;
    _imageView.frame = frame;
    _collectionView.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    } completion:^(BOOL finished) {
    //先通知上层返回
    _finishHideBlock();
    //重置状态
    _imageView.frame = [self imageViewFrame];
    _scrollView.contentInset = UIEdgeInsetsZero;
    }];
    }
    } else {
    //拖拽过程中逐渐改变透明度
    _scrollView.contentInset = UIEdgeInsetsMake(-_scrollView.contentOffset.y, 0, 0, 0);
    CGFloat alpha = 1 - ABS(_scrollView.contentOffset.y / (_scrollView.bounds.size.height));
    _collectionView.backgroundColor = [UIColor colorWithWhite:0 alpha:alpha];
    _startHideBlock();
    }
    }

@lvpeng0412
Copy link

scrollViewDidScroll 里面的代码可以去掉,
下面加一行
_collectionView.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
就可以修复这个问题

@ghost
Copy link
Author

ghost commented Jan 19, 2018

好的 谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant