Troubles using CGPathContainsPoint SWIFT

吃可爱长大的小学妹 提交于 2019-12-10 02:02:10

问题


I need to check if a CGPoint is inside a SKSpriteNode.

After a little research, CGPathContainsPoint seems appropriated for my purpose.

if CGPathContainsPoint(my_sprite_path, nil, my_point, false) {

 }

But Xcode alerts me: Use of unresolved identifier CGPathContainsPoint

I tried to import :

import UIKit
import CoreGraphics

I'm using Xcode 8.0 beta 6.

Did I miss anything?


回答1:


As of Swift 3, many Core Graphics functions are now methods on the corresponding type. In your example:

if my_sprite_path.contains(my_point) {

}

For more information see SE-044 Import as member.



来源:https://stackoverflow.com/questions/39027603/troubles-using-cgpathcontainspoint-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!