【发布时间】:2018-04-01 11:12:40
【问题描述】:
我已经在我的应用中实现了这段代码
Converting UIImageView Touch Coordinates to UIImage Coordinates
这段代码就像一个魅力,但我正在尝试做同样的事情,但使用 Aspect Fill,据我了解,de 代码将不起作用,因为如果图像更小会缩放更大,所以我看不到部分在宽高比与图像不同的情况下,图像的大小。
这是我正在实现的代码:
private func pointConversion(point: CGPoint) -> CGPoint {
if let image = self.imageView.image {
let percentX = point.x / self.imageView.frame.size.width
let percentY = point.y / self.imageView.frame.size.height
return CGPoint(x: image.size.width * percentX , y: image.size.height * percentY)
}
return CGPoint(x: 0, y: 0)
}
提前致谢。
【问题讨论】:
标签: ios iphone swift uiimageview uiimage