La taille de l'image pin annotation
J'ai mis l'image au lieu de la traditionnelle rouge pin. Quand j'ai ouvert la carte pour afficher le pin, l'image de couverture de l'ensemble de la carte. Est-il une taille maximale de la broche de l'image ou comment puis-je intégrer quelque chose dans le code pour l'adapter à la taille standard classique nip?
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let annotationIdentifier = "SomeCustomIdentifier" //use something unique that functionally identifies the type of pin
var annotationView: MKAnnotationView! = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationIdentifier)
if annotationView != nil {
annotationView.annotation = annotation
} else {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView.image = UIImage(named: "pin maps.png")
annotationView.canShowCallout = true
annotationView.calloutOffset = CGPointMake(-8, 0)
annotationView.autoresizesSubviews = true
annotationView.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView
}
return annotationView
}
OriginalL'auteur Riccardo Caroli | 2015-10-21
Vous devez vous connecter pour publier un commentaire.
Il n'y a pas de taille maximale de la broche de l'image. Vous avez besoin de redimensionner UIImage.
pinImage.tirage au sort(dans: CGRect(x:0, y:0, largeur:taille.la largeur, la hauteur:la taille.hauteur))
Je voudrais utiliser: anView?.cadre.size = CGSize(largeur: 30, hauteur: 40) au Lieu de tous les drawContext trucs
OriginalL'auteur Kosuke Ogawa