繁体   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