滚动时Swift图像调整大小

时间:2015-10-08 13:07:01

标签: ios iphone image swift scrollview

我正在尝试实现此图像动画?

其自动输出和图像大小调整。有谁知道怎么做?

here is what am i looking for

这是我的代码

 /*
* Image resizing
*/
func scrollViewDidScroll(scrollView: UIScrollView) {
    let top: CGFloat = scrollView.contentOffset.y
    let newWidth: CGFloat = self.view.bounds.size.width
    let new: CGFloat = 200 - top
    if top >= -64 {
        self.imageView.frame = CGRectMake(0, 0 - top, self.view.bounds.size.width, 220)
        //imageView.si
    }
    if top < -64 {
        var imgViewRect: CGRect = self.imageView.frame
        imgViewRect.size.height = new
        imgViewRect.size.width = newWidth - top
        self.imageView.frame = CGRectMake(32 + (top / 2), 64, self.view.frame.size.width - (top + 64), imgViewRect.size.height - 44)

    }
}

0 个答案:

没有答案