嘿,我收到这个错误,这是我下面的代码,我有 import simd 但它不起作用。
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = panningTouch {
let displacement = float2(touch.location(in: view)) - float2(touch.previousLocation(in: view))
panCamera(displacement)
}
}
最佳答案
如错误消息所述,simd.float2
没有采用 CGPoint
的初始化器。但是,您可以添加自己的:
extension float2 {
init(_ point: CGPoint) {
self.init(Float(point.x), Float(point.y))
}
}
关于ios - 无法使用类型为 'float2' 的参数列表调用类型为 'CGPoint' 的初始值设定项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42102508/