我正在尝试初始化 CGContext ( API )
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let url = NSURL.fileURL(withPath: documentsPath + "/datafile")
if let context = CGContext(url: url as CFURL) {
// stuff
}
但这给了我错误:
Cannot invoke initializer for type 'CGContext' with an argument list of type '(url: CFURL)'
我也试过CGContext(url as CFURL)
了CGContext.init(url as CFURL)
如果我添加mediaBox: nil
我得到:
Ambiguous reference to member 'init(data:width:height:bitsPerComponent:bytesPerRow:space:bitmapInfo:releaseCallback:releaseInfo:)