CGPoint 编译器错误

CGPoint compiler error

我试过写一个表达式:

 var  moveDifference: CGPoint = CGPoint(touchPoint.x - self.anchorPointInPoints().x, touchPoint.y - self.anchorPointInPoints().y)

但是xcode发誓:

Argument labels '(_:, _:)' do not match any available overloads

请帮忙解决这个问题。

提前致谢。

您错过了 CGPoint 初始值设定项中的 参数标签

CGPoint(x: ..., y: ...)

此外:感谢类型推断,您真的不需要重新声明您的 var 类型:

var moveDifference = CGPoint(...