我在
swift中有以下代码,不能编译:
原文链接:https://www.f2er.com/swift/318783.htmlclass 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?