I'm drawing a wave in drawRect
method but it appears on the screen all of sudden. I want to animate the process of wave creation e.g wave should be created slowly step by step so that user can see it.
this is the code i am using for drawing my wave
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 2.0)
GContextSetStrokeColorWithColor(context, UIColor.redColor().CGColor)
var startX : CGFloat = 10
var EndX : CGFloat = 30
var CpX : CGFloat = 20
var CpY : CGFloat = 160
var Y : CGFloat = 200
for(var i = 0 ; i<5 ; i++ )
{
CGContextMoveToPoint(context, startX, Y)
CGContextAddQuadCurveToPoint(context, CpX, 160, EndX, 200)
CGContextStrokePath(context)
startX += 20
CpX += 20
EndX += 20
CGContextMoveToPoint(context, startX, Y)
CGContextAddQuadCurveToPoint(context, CpX, 240, EndX, 200)
CGContextStrokePath(context)
CpX += 20
startX += 20
EndX += 20
}
}