当我向下滚动表格时,如何放大uiimageview?

vee*_*eev 1 iphone uiscrollview uiimageview uiscrollviewdelegate

大家好,我正在尝试放大uiimageview使用动画,因为我正在向下滚动uiscrollview.请注意它不是关于uiimageview放大和缩小uiscrollview.

我能够检测到我向下滚动的程度:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
Run Code Online (Sandbox Code Playgroud)

我需要根据(滚动因子)缩小图像我向下滚动多少.知道如何做到这一点?

在此输入图像描述

And*_*scu 10

我建议改变transform你想要缩放的图像的属性

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

    // this is just a demo method on how to compute the scale factor based on the current contentOffset
    float scale = 1.0f + fabsf(scrollView.contentOffset.y)  / scrollView.frame.size.height; 

    //Cap the scaling between zero and 1
    scale = MAX(0.0f, scale);

    // Set the scale to the imageView
    imageView.transform = CGAffineTransformMakeScale(scale, scale);    
}
Run Code Online (Sandbox Code Playgroud)

如果您还需要滚动视图转到顶部,则图像视图已缩小,然后您需要调整滚动视图和图像视图的框架.

也许你可以告诉我们更多你想要的效果.