-1
내 맞춤 이미지 대신 맞춤 핀 이미지를 내지도보기에 표시하려고하는데 일반 빨간색 핀이 표시됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?맞춤 핀 이미지 표시 안 함
ViewFor 주석 :
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let reuseID = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseID) as? MKPinAnnotationView
if(pinView == nil) {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseID)
pinView!.canShowCallout = true
pinView!.animatesDrop = false
pinView?.image = UIImage(named: "CustomPinImage")
pinView!.rightCalloutAccessoryView = UIButton(type: UIButtonType.detailDisclosure) as UIButton
let smallSquare = CGSize(width: 40, height: 40)
let button = UIButton(frame: CGRect(origin: CGPoint.zero, size: smallSquare))
button.setBackgroundImage(UIImage(named: "Car2"), for: UIControlState())
pinView?.leftCalloutAccessoryView = button
}
else
{
pinView?.annotation = annotation
}
return pinView
}
것은 내가 표시하고있어 어떻게 핀 : 그 누구도 날이 밖으로 정렬하는 데 도움 수 있다면
let LitzmanLocation = CLLocationCoordinate2DMake(32.100668,34.775192)
let Litzman = MKPointAnnotation()
Litzman.coordinate = LitzmanLocation
Litzman.title = "Litzman Bar"
Litzman.subtitle = "נמל תל אביב 18,תל אביב"
mapView.addAnnotation(Litzman)
그것은 좋은 것입니다!
감사합니다 :)
감사합니다! 작동! –