简体   繁体   English

表达式解析为未使用的函数:CGContext.saveGState

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

I am writing the code to draw image pattern but for the function CGContext.saveGState(), I am receiving error as Expression resolves to an unused function. 我正在编写代码以绘制图像图案,但是对于函数CGContext.saveGState(),由于Expression解析为未使用的函数,因此收到错误。

can anybody help to write same in swift 3.0. 任何人都可以帮助在Swift 3.0中编写相同的内容。 below is the code snippet: 下面是代码片段:

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!)

Thanks in advance 提前致谢

Just call saveGState directly on context object like this: 只需像这样直接在上下文对象上调用saveGState:

context?.saveGState()

Instead of: 代替:

CGContext.saveGState(context!)

Try this code: 试试这个代码:

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