问题 
我想计算发送到另一部手机时 touch.location 的响应 
- override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
 
 -     swiped = false
 
 -     if let touch = touches.first {
 
 -         lastPoint = touch.location(in: self.imageView)
 
 -         print (lastPoint.x)
 
 -     }
 
 - }
 
  复制代码 
注意 iPhone 8 屏幕底部的黑线位于 iPhone 11 promax 的中心 
 
在 iPhone 8 模拟器上 
 
在 iphone11promax 模拟器上 
 
回答 
现在,你正在做这样的事情: 
 
该点将更靠近左上角,因为 CGPoint(x:30, y:40) 更靠近像素密度较高的手机的左上角。 
 
相反,请尝试以下操作: 
 
一。从手机 A 获取点,即 100 x 100 像素。然后除以高度和宽度。点是 CGPoint(x: 0.3, y: 0.4)。 
 
2. 用宽和高相乘显示手机B上的点。 0.3*200=60,0.4*200=80。该点现在将正确显示。 
 
这仅在两部手机具有相同的纵横比时才有效,否则图像将被拉伸以填充目标手机。 
 
 
 
 |