swift 3和CGContextEOClip

rez*_*a23 4 swift3 ios10

当我将我的代码转换为swift 3时,我收到了这个错误:

error: 'CGContextEOClip' is unavailable: Use clip(using:)
                                CGContextEOClip(context!);
                                ^~~~~~~~~~~~~~~
CoreGraphics.CGContextEOClip:2:13: note: 'CGContextEOClip' has been explicitly marked unavailable here
public func CGContextEOClip(_ c: CGContext?)
Run Code Online (Sandbox Code Playgroud)

我不知道如何使用剪辑(使用:),我没有看到任何与它相关的文档.有任何想法吗.谢谢Reza

Jan*_*ans 9

在swift3中CGContextEOClip,CGContextClip现在是CGContext类型的方法

let context = /*your context*/
context.clip(using: .evenOdd) // for CGContextEOClip
context.clip(using: .winding) // for CGContextClip
Run Code Online (Sandbox Code Playgroud)