Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For Michael Tyson's response (I can't comment everywhere yet), I propose an insertion of the following code in didMoveToSuperview for proper reuse of MKAnnotationView so it does the animation again and then imitate the sequencial addition of annotations</p> <p>Play with the dividers and multipliers for different visual results...</p> <pre><code>- (void)didMoveToSuperview { //necessary so it doesn't add another animation when moved to superview = nil //and to remove the previous animations if they were not finished! if (!self.superview) { [self.layer removeAllAnimations]; return; } float xOriginDivider = 20.; float pos = 0; UIView *mySuperview = self.superview; while (mySuperview &amp;&amp; ![mySuperview isKindOfClass:[MKMapView class]]) mySuperview = mySuperview.superview; if ([mySuperview isKindOfClass:[MKMapView class]]) //given the position in the array // pos = [((MKMapView *) mySuperview).annotations indexOfObject:self.annotation]; // left to right sequence; pos = [((MKMapView *) mySuperview) convertCoordinate:self.annotation.coordinate toPointToView:mySuperview].x / xOriginDivider; float yOffsetMultiplier = 20.; float timeOffsetMultiplier = 0.05; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; animation.duration = 0.4 + timeOffsetMultiplier * pos; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, -400 - yOffsetMultiplier * pos, 0)]; animation.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; // rest of animation group... } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload