I'm trying to simulate an animation of a user's location in MapKit (somewhere, the user's position is represented by a pulsating blue dot). I created my own subclass of MKAnnotationView and in the drawRect method, which I am trying to execute through a set of colors. Here's a simpler implementation of what I'm doing:
- (void)drawRect:(CGRect)rect {
float magSquared = event.magnitude * event.magnitude;
CGContextRef context = UIGraphicsGetCurrentContext();
if (idx == -1) {
r[0] = 1.0; r[1] = 0.5; r[2] = 0;
b[0] = 0; b[1] = 1.0; b[2] = 0.5;
g[0] = 0.5; g[1] = 0; g[2] = 1.0;
idx = 0;
}
CGContextSetRGBFillColor(context, r[idx], g[idx], b[idx], 0.75);
CGContextFillEllipseInRect(context, rect);
idx++;
if (idx > 3) idx = 0;
}
Unfortunately, this simply makes annotations be one of three different colors and does not go through them. Is there a way to make MKAnnotations constantly redraw so that it looks animated?
source
share