7
मैंने पारंपरिक लाल पिन की बजाय व्यक्तिगत छवि डाली। जब मैं पिन प्रदर्शित करने के लिए मानचित्र खोलता हूं, तो छवि पूरे मानचित्र को कवर करती है। क्या पिन छवि का अधिकतम आकार है या आकार मानक क्लासिक पिन फिट करने के लिए कोड में कुछ कैसे एकीकृत किया जाए?आकार छवि पिन एनोटेशन
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
}
यह कहता है ** CGRectMake ** pinImage.draw (में: CGRect (एक्स: 0, y: 0, चौड़ाई: size.width, ऊंचाई: size.height)) swft – Saneth
में नहीं है –
मैं करूंगा उपयोग करें: anView? .frame.size = CGSize (चौड़ाई: 30, ऊंचाई: 40) सभी drawContext सामग्री के बजाय –