iphone - 向下滚动表格时如何放大 uiimageview?

标签 iphone uiscrollview uiimageview uiscrollviewdelegate

大家好,我正在尝试在向下滚动 uiscrollview 时使用动画来放大 uiimageview。请注意,这与在 uiscrollview 中放大和缩小 uiimageview 无关。

我能够检测到我向下滚动了多少:

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

我需要缩小图像,具体取决于(滚动系数)我向下滚动的程度。知道如何做到这一点吗?

enter image description here

最佳答案

我建议更改您要缩放的图像的 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/

相关文章:

iphone - 未显示 UIToolbar

iphone - 将值从 UIView 传递到 UIViewController

ios - 需要帮助在多个 View 上实现滚动条

iPhone页面 curl 过渡动画

ios - 如何为每个数组保存图像

iphone - 来自编码未知的文本文件的 NSString

ios - 此包无效 - Info.plist 中索引 327 处的无效 XML 字符 '0x10'

ios - 在 iOS 设备上交互显示 ppt

ios - 如何在表格的开头和结尾锁定表格 View 滚动

ios - 如何设置UIimagePickerController