- (void)drawRect:(CGRect)rect {
CGContextRef s = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(s, 250, 5, 5, 1);
CGContextFillRect(s, CGRectMake(2, 2, 2, 2));
[UIView beginAnimations:nil context:s];
[UIView setAnimationDuration: .5];
[UIView setAnimationDelegate:self];
//animation goes here
vector<CGPoint>::iterator L = dp.dPoints->begin();
while(L != dp.dPoints->end()){
CGContextAddLineToPoint(s, (*L).x, (*L).y);
++L;
}
[UIView commitAnimations];
}
What i would like to do is take a rectangle made in CGContext and with the use of UIViews animation, it trace (in an endless Animation) a stroke line created with CGContext.
I am rather unsure how i would go about tracing my line…
Any help, links or comments would be great thanks.
http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/
draw a curved line
keyframe animation, and a path that is the same as the line we just drew. We will also draw a circle, and animate it along that path:
To get all this running, you can use this init method:
and use something like this in your ViewController
Also…don’t forget to add your Quartz import: