ios:ScrollView联动效果

孔建柏
2023-12-01

1.简单的效果 简单的代码

2.主要用到scrollViewDidScroll代理方法   代码如下

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    float bigX = _fScrollView.bounds.size.width/_sScrollView.bounds.size.width;
    float littleX = _sScrollView.bounds.size.width/_fScrollView.bounds.size.width;
    if (scrollView == _fScrollView) {
        _sScrollView.delegate = nil;
        _sScrollView.contentOffset = CGPointMake(scrollView.contentOffset.x * littleX, scrollView.contentOffset.y);
        _sScrollView.delegate = self;
    }
    else
    {
        _fScrollView.delegate = nil;
        _fScrollView.contentOffset = CGPointMake(scrollView.contentOffset.x * bigX, scrollView.contentOffset.y);
        _fScrollView.delegate = self;
    }
}

 3.demo (这个功能其实运用很广泛)

http://pan.baidu.com/s/1i3vFFaH

ps:说些题外话,发现之前写的都是各种效果,其实都是很基础的东西。最近比较浮躁,要沉淀沉淀了

转载于:https://www.cnblogs.com/yoon/p/3857421.html

 类似资料: