禁止scrollView滚动

1. 禁止上下滚动

contentsize.height =0即可

2.禁止左右滚动

contentsize.width = 0即可

3.禁止滚动

contentsize.height =0; contentsize.width = 0;

但是用 scrollEnabled = NO; 更方便

4.禁止下滚动

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.y <= 0.0) {
        CGFloat sizeWidth = scrollView.contentSize.width;
        CGFloat sizeHeght = scrollView.contentSize.height;

        [scrollView setContentSize:CGSizeMake(sizeWidth, 0)];
        [scrollView setContentSize:CGSizeMake(sizeWidth, sizeHeght)];

    }
}

4.禁止上滚动

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.y >= 0.0) {
        CGFloat sizeWidth = scrollView.contentSize.width;
        CGFloat sizeHeght = scrollView.contentSize.height;

        [scrollView setContentSize:CGSizeMake(sizeWidth, 0)];
        [scrollView setContentSize:CGSizeMake(sizeWidth, sizeHeght)];

    }
}
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 撸撸猫 设计师: 设计师小姐姐
应支付0元
点击重新获取
扫码支付

支付成功即可阅读