我想初始化CGContext上(API)初始化CGContext上
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:)
查找文檔:https://developer.apple.com/documentation/coregraphics/cgcontext/1456290-init。初始化程序需要*三個*參數。 –