Swift 3和CGContextEOClip

5

在将我的代码转换为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:),也没有看到任何相关的文档。有什么想法吗?谢谢,Reza。

1个回答

10

在 Swift 3 中,CGContextEOClipCGContextClip 现在是 CGContext 类型的方法。

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

是的。CGContextEOClipCGContextClip,这两个函数曾经用于剪切时可能出现的两种不同填充规则,现在已经合并为一个方法,并接受一个填充规则参数。 - rickster

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接