您能帮我解决这个问题吗,因为我没有任何想法来解决它。
for (x,height) in variances.enumerated()
{
let p = CGPoint(x: step + waveWidth*CGFloat(x), y: self.frame.size.height/2)
let cp1 = CGPoint(x: p.x - (3.0/4.0)*waveWidth ,y: p.y + (waveHeight + CGFloat(variance/2) - height))
let cp2 = CGPoint(x: p.x - (1.0/4.0)*waveWidth, y: p.y - (waveHeight + CGFloat(variance/2) - height))
CGContextAddCurveToPoint(context, cp1.x, cp1.y, cp2.x, cp2.y, p.x, p.y)
}
最佳答案
阅读swift-evolution和 Xcode 8 Release Notes .
总结:在 Swift 3 中,CoreGraphics 等框架的 C 函数声明不会导入为 CGContextDoSomething: CGContext -> T -> U
,而是类似于 CGContext 类型的成员方法。所以它必须这样调用:
let context: CGContext = <…> // Get CGContext instance, how is irrelevant for example
context.doSomething(<…>)
您还应该尝试使用曲线添加 CGPath 而不是直接在上下文中绘制。
关于ios - cgcontextaddcurvetopoint 在 swift 3 中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39997523/