为什么“nil"与“UnsafePointer<CGAffineTransform>"不兼容在 Swift 3 中? [英] Why is 'nil' not compatible with 'UnsafePointer<CGAffineTransform>' in Swift 3?

查看:18
本文介绍了为什么“nil"与“UnsafePointer<CGAffineTransform>"不兼容在 Swift 3 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建一个 CGMutablePath() 如下:

Trying to create a CGMutablePath() as such:

let path = CGMutablePath()
CGPathMoveToPoint(path, nil, 30, 0)

但编译器不断给我以下错误:'nil' not compatible with expected argument type 'UnsafePointer<CGAffineTransform>'.我究竟做错了什么?我似乎无法在网上找到其他任何东西.(是的,我已经尝试将 Ints 转换为 CGFloats,但似乎没有什么区别.)

but the compiler keeps on giving me the following error: 'nil' not compatible with expected argument type 'UnsafePointer<CGAffineTransform>'. What am I doing wrong? I can't seem to find anything else online. (Yes I've tried converting the Ints to CGFloats but it doesn't seem to make a difference.)

推荐答案

试试这个:

let path = CGMutablePath()
path.move(to: CGPoint(x: 30, y: 0))

CGPath API 现在在 Swift 3 中作为实例方法导入.您可以通过按住 Command 键单击 CGMutablePath 来检查它们.或者查看CGMutablePath的最新参考.

CGPath APIs are now imported as instance methods in Swift 3. You can check them with Command-clicking on CGMutablePath. Or see the latest reference of CGMutablePath.

这篇关于为什么“nil"与“UnsafePointer&lt;CGAffineTransform&gt;"不兼容在 Swift 3 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆