Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 缩放不同屏幕尺寸的触摸点_Ios_Swift_Uitouch_Cgpoint - Fatal编程技术网

Ios 缩放不同屏幕尺寸的触摸点

Ios 缩放不同屏幕尺寸的触摸点,ios,swift,uitouch,cgpoint,Ios,Swift,Uitouch,Cgpoint,给定一个CGPoint接触点,是否有办法缩放x、y值,使其在所有屏幕尺寸/分辨率、不同的iPad、不同的iPhone上保持一致?选择标准尺寸,将要插值的点乘以当前宽度/高度和标准宽度/高度的商 guard let currentSize = (UIApplication.shared.delegate as? AppDelegate)?.window?.bounds.size else { return } let standardSize = CGSize(width: 320, h

给定一个CGPoint接触点,是否有办法缩放x、y值,使其在所有屏幕尺寸/分辨率、不同的iPad、不同的iPhone上保持一致?

选择标准尺寸,将要插值的点乘以当前宽度/高度和标准宽度/高度的商

guard let currentSize = (UIApplication.shared.delegate as? AppDelegate)?.window?.bounds.size else {
    return
}

let standardSize = CGSize(width: 320, height: 568)
let point = CGPoint(x: 120, y: 120)
let interpolatedPoint = CGPoint(x: point.x * currentSize.width / standardSize.width, y: point.y * currentSize.height / standardSize.height)

你说一致是什么意思?