swift3 – CGPath在Swift 3中不起作用

参见英文答案 > 1. CGPathMoveToPoint’ is unavailable: Use move(to:transform:) 2. ‘CGPathAddLineToPoint’ is unavailable: Use addLine(to:transform:)1个
我正在更新swift 3的代码.我已经为swift 2中的spritekit对象创建一个自定义路径.但是,现在我得到一个编译器错误

Nil is not compatible with expected argument type ‘Unsafe Pointer CGAffineTransform’

let offsetX = player.size.width * player.anchorPoint.x
let offsetY = player.size.height * player.anchorPoint.y

let path = CGMutablePath()

CGPathMovetoPoint(path,nil,10 - offsetX,16 - offsetY)
CGPathAddLinetoPoint(path,0 - offsetY)
CGPathAddLinetoPoint(path,24 - offsetX,28 - offsetX,40 - offsetY)
CGPathAddLinetoPoint(path,18 - offsetX,46 - offsetY)
CGPathAddLinetoPoint(path,6 - offsetX,36 - offsetY)
CGPathAddLinetoPoint(path,18 - offsetY)



path.closeSubpath()

错误是在添加到路径时在第二个参数中传递nil.我尝试传入一个不安全的指针,如下所示:

var tr = CGAffineTransform.identity
CGPathMovetoPoint(path,&tr,16 - offsetY)
....

但后来又有了一个奇怪的错误.

CGPathMovetoPoint is unavailable. Use move(to: transform:)

但是,没有带参数名称的移动函数.然而,有一个举动(toParent:).

大多数语法在Swift 3中都有所改变,但是他们没有删除任何API方法(比如CGPathMovetoPoint),它只是重命名如下.
let path = CGMutablePath()
path.move(to: CGPoint(x: 10.0,y: 10.0))
path.addLine(to: CGPoint(x: 10.0,y: 10.0))

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...