J'ai utilisé des images broche dans l'application à la place de la broche standard, maintenant je veux donner de l'animation (effet de chute comme c'était le cas avec les broches standard) aux broches personnalisées. Comment est-ce que je peux fournir l'effet d'animation de baisse aux images faites sur commande de broche ????Animation de broche personnalisée - MKMapView
Répondre
Implémentez la méthode de délégation suivante.
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
for (aV in views) {
CGRect endFrame = aV.frame;
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - 230.0, aV.frame.size.width, aV.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.45];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[aV setFrame:endFrame];
[UIView commitAnimations];
}
}
Cela a bien fonctionné. Doit être marqué réponse correcte. –
Il sent aussi beaucoup plus frais si vous ne laissez pas tomber toutes les broches à la fois, mais laissez tomber chacun d'eux avec un petit retard pour qu'il regardera comme il y a une pluie d'effet broches. Semblable à ce que Apple fait nativement. Utilisez ceci:
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
float delay = 0.00;
for (aV in views) {
CGRect endFrame = aV.frame;
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - 430.0, aV.frame.size.width, aV.frame.size.height);
delay = delay + 0.01;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:delay];
[UIView setAnimationDuration:0.45];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[aV setFrame:endFrame];
[UIView commitAnimations];
}
}
Oui, c'est cool! Merci – PrasadW
Cela a bien fonctionné pour moi. Rappelez-vous où je ne peux pas trouvé ici si
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
for (aV in views) {
// Don't pin drop if annotation is user location
if ([aV.annotation isKindOfClass:[MKUserLocation class]]) {
continue;
}
// Check if current annotation is inside visible map rect, else go to next one
MKMapPoint point = MKMapPointForCoordinate(aV.annotation.coordinate);
if (!MKMapRectContainsPoint(self.mapView.visibleMapRect, point)) {
continue;
}
CGRect endFrame = aV.frame;
// Move annotation out of view
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - self.view.frame.size.height, aV.frame.size.width, aV.frame.size.height);
// Animate drop
[UIView animateWithDuration:0.3 delay:0.03*[views indexOfObject:aV] options:UIViewAnimationCurveLinear animations:^{
aV.frame = endFrame;
// Animate squash
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.05 animations:^{
aV.transform = CGAffineTransformMakeScale(1.0, 0.8);
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.5 animations:^{
aV.transform = CGAffineTransformIdentity;
}];
}
}];
}
}];
}
}
Notez que l'animation de la vue d'annotation dans -mapView:didAddAnnotationViews:
provoque des effets étranges lorsque MKMapView.userTrackingMode
est égal à MKUserTrackingModeFollowWithHeading
. Je souhaite juste qu'Apple a rendu l'animation disponible à la classe MKAnnotationView
.
Swift 3 animation goutte
// animate annotation views drop
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
for annView in views {
// animate any annotation views except the user pin
if !(annView.annotation?.isKind(of: MKUserLocation.self))! {
let endFrame = annView.frame
annView.frame = endFrame.offsetBy(dx: 0, dy: -500)
UIView.animate(withDuration: 0.5, animations: {
annView.frame = endFrame
})
}
}
- 1. UILabel au lieu de la broche par défaut sur MKMapView
- 2. Plusieurs couleurs de broche sur la même carte dans MKMapView
- 3. MKMapView: Obtention d'un événement cliqué sur la broche d'annotation
- 4. Broche personnalisée avec sous-titre titre iphone
- 5. Animation d'une légende personnalisée pour MKAnnotationView dans MKMapView avec effet "pop-in"
- 6. Animation personnalisée dans Android
- 7. iPhone Core Location: Différencier broches pour l'image de la broche personnalisée
- 8. animation d'une propriété CALayer personnalisée
- 9. Android MapView: animation personnalisée possible?
- 10. Animation personnalisée Voir la classe
- 11. A propos MKMapView
- 12. MKMapView Affichage de l'emplacement actuel
- 13. MkMapView Niveau de zoom
- 14. Problème de changement de couleur de la broche iOS MapKit
- 15. Comment créer une animation Core Curl personnalisée?
- 16. Animation personnalisée pour pousser un UIViewController
- 17. MKMapView question de localisation GPS
- 18. Pourquoi une broche placée à la même latitude et à la même longitude dans MKMapView diffère-t-elle d'une broche dans Google Maps?
- 19. Coins arrondis de MKMapView
- 20. WAP + NUnit + WebConfigurationManager Broche
- 21. Restreindre le défilement MKMapView
- 22. lors de l'actualisation du MKMapView, la broche d'emplacement actuelle doit se déplacer doucement ou animer à sa position actuelle
- 23. Comment passer à une autre vue sur le clic de la broche d'annotation dans MKMapView dans iPhone SDK?
- 24. animation pour la propriété personnalisée du type de collection
- 25. Développement de l'iPhone - L'annotation de broche dans une région de carte visible
- 26. Problème avec l'annotation de carte et MKMapView dans iOS 4.2?
- 27. Icône de carte Google (broche) - comment définir la couleur?
- 28. Erreur de lien MKMapView
- 29. MKMapView: comment amener MKUserLocationView (le point bleu) devant?
- 30. MKMapView disposition
[Cela devrait aider] (http://stackoverflow.com/questions/1857160/how-can-i-create-a-custom-pin-drop- animation-using-mkannotationview) – dwery