如何在swift中将COpaquePointer转换为某种类型(特别是CGContext
发布时间:2020-12-14 05:41:31 所属栏目:百科 来源:网络整理
导读:我在 swift中有以下代码,不能编译: class CustomView: NSView { override func drawRect(dirtyRect: NSRect) { var contextPointer: COpaquePointer = NSGraphicsContext.currentContext()!.graphicsPort() var context: CGContext? = contextPointer as? C
我在
swift中有以下代码,不能编译:
class CustomView: NSView { override func drawRect(dirtyRect: NSRect) { var contextPointer: COpaquePointer = NSGraphicsContext.currentContext()!.graphicsPort() var context: CGContext? = contextPointer as? CGContext CGContextSetRGBFillColor(context,1,1) CGContextFillRect(context,CGRectMake(0,100,100)) CGContextFlush(context) } } 如何将COpaquePointer转换为CGContext?
从Developer Preview 5开始,NSGraphicsContext现在具有CGContext属性.它还没有记录,但它在头文件中:
@property (readonly) CGContextRef CGContext NS_RETURNS_INNER_POINTER NS_AVAILABLE_MAC(10_10); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |