swift 3 和 CGContextEOClip

swift 3 and CGContextEOClip

当我将我的代码转换为 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?)

我不知道如何使用 clip(using:),也没有看到任何相关文档。 有任何想法吗。 谢谢 礼萨

在 swift3 中 CGContextEOClipCGContextClip 现在是 CGContext 类型的方法

let context = /*your context*/
context.clip(using: .evenOdd) // for CGContextEOClip
context.clip(using: .winding) // for CGContextClip