Reputation: 1325
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.
can anybody help to write same in 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
Upvotes: 1
Views: 798
Reputation: 3383
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()
Upvotes: 1
Reputation: 597
Just call saveGState directly on context object like this:
context?.saveGState()
Instead of:
CGContext.saveGState(context!)
Upvotes: 4