我不明白zoomToRect如何在Swift中工作

时间:2015-08-24 18:24:31

标签: ios swift

有人可以向我解释这段代码吗?这是用于使用Swift在iOS应用中缩放图像,但我不明白为什么它正在工作

let scrollViewSize = scrollView.bounds.size
let w = scrollViewSize.width / newZoomScale
let h = scrollViewSize.height / newZoomScale
let x = pointInView.x - (w / 2.0)
let y = pointInView.y - (h / 2.0)
let rectToZoomTo = CGRectMake(x, y, w, h);

scrollView.zoomToRect(rectToZoomTo, animated: true)

作为致敬,这段代码片段来自ray wanderlich教程

0 个答案:

没有答案