【发布时间】:2014-06-03 07:21:32
【问题描述】:
我在 swift 中有以下无法编译的代码:
class CustomView: NSView {
override func drawRect(dirtyRect: NSRect) {
var contextPointer: COpaquePointer = NSGraphicsContext.currentContext()!.graphicsPort()
var context: CGContext? = contextPointer as? CGContext
CGContextSetRGBFillColor(context, 1, 0, 0, 1)
CGContextFillRect(context, CGRectMake(0, 0, 100, 100))
CGContextFlush(context)
}
}
如何将 COpaquePointer 转换为 CGContext?
【问题讨论】:
标签: swift