Gautam Sareriya
Gautam Sareriya

Reputation: 1833

cgcontextaddcurvetopoint is unavailable in swift 3

Can you please help me to resolve this issue as I am not getting any idea to resolve it.

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)

    }

Upvotes: 0

Views: 712

Answers (1)

user28434'mstep
user28434'mstep

Reputation: 6600

Read swift-evolution and Xcode 8 Release Notes.

Summary: In Swift 3 C-function declarations from Frameworks like CoreGraphics are not imported as CGContextDoSomething: CGContext -> T -> U but like member methods of type CGContext. So it must be called like:

let context: CGContext = <…> // Get CGContext instance, how is irrelevant for example
context.doSomething(<…>)

Also you should try adding CGPath with curve instead of directly drawing in context.

Upvotes: 1

Related Questions