簡體   English   中英

表達式解析為未使用的函數:CGContext.saveGState

[英]Expression resolves to an unused function: CGContext.saveGState

我正在編寫代碼以繪制圖像圖案,但是對於函數CGContext.saveGState(),由於Expression解析為未使用的函數,因此收到錯誤。

任何人都可以幫助在Swift 3.0中編寫相同的內容。 下面是代碼片段:

UIGraphicsBeginImageContext(view.frame.size)
tempImageView.image?.draw(in: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
let context = UIGraphicsGetCurrentContext()
CGContext.saveGState(context!)

提前致謝

只需像這樣直接在上下文對象上調用saveGState:

context?.saveGState()

代替:

CGContext.saveGState(context!)

試試這個代碼:

UIGraphicsBeginImageContext(view.frame.size)
tempImageView.image?.draw(in: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
let context = UIGraphicsGetCurrentContext()
context?.saveGState()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM