我是 swift 的新手,很明显代码在不断变化。我目前正在完成 youtube 教程- https://www.youtube.com/watch?v=rvKyeOqMldA ,我发现它很有趣,但在教程 10 分钟后无法继续。我收到以下错误消息: See details below: "CGContextAddEllipseInRect' has been replaced by instance method 'CGContext.addEllipse(in:)"
最佳答案
请阅读并尝试理解错误消息。有时 Xcode 的错误消息会让初学者感到困惑,但这一条非常清楚,因为编译器会立即向您显示替换信息:
CGContextAddEllipseInRect' has been replaced by instance method 'CGContext.addEllipse(in:)
表示代替函数
CGContextAddEllipseInRect(context, imgRect)
你必须在 CGContext
实例上调用 addEllipse(in:)
:
let context = UIGraphicsGetCurrentContext()!
context.addEllipse(in: imgRect)
使用代码完成查看方法的完整签名以及如何应用参数。
关于ios - 快速替换 CGContextAddEllipseInRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49082142/