大家好,我正在尝试在向下滚动 uiscrollview
时使用动画来放大 uiimageview
。请注意,这与在 uiscrollview
中放大和缩小 uiimageview
无关。
我能够检测到我向下滚动了多少:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
我需要缩小图像,具体取决于(滚动系数)我向下滚动的程度。知道如何做到这一点吗?
最佳答案
我建议更改您要缩放的图像的 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);
}
如果你还需要scrollview到顶部,imageview已经缩小了,那么你需要调整scrollview和imageview的frame。
或许您可以告诉我们更多您想要的效果。
关于iphone - 向下滚动表格时如何放大 uiimageview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18015744/