I am trying to make the annotation call out box as it would have no colour and be completely transparent.
the code is the following:
import Foundation
import MapKit
class CustomPin: NSObject, MKAnnotation
{
var coordinate: CLLocationCoordinate2D
var title: String?
init(pinTitle: String, location: CLLocationCoordinate2D) {
self.title = pinTitle
self.coordinate = location
}
}
func setPin(location: CLLocationCoordinate2D)
{
let pin = CustomPin(pinTitle:"" ,location: location)
self.mapView.addAnnotation(pin)
self.mapView.delegate = self
print(location.latitude)
print(location.longitude)
}
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
{
let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "customAnnotation")
annotationView.image = UIImage(named: "marker")
annotationView.canShowCallout = true
annotationView.detailCalloutAccessoryView = addressLabel
return annotationView
}
The result is show like this:
The desired result should be like this:
What is there to modify?
I've looked a little and I don't think Apple has anything you can do directly to the callout appearance other than modifying left and right accessoryViews. I think you have to create your own custom callouts.
Check this out if you're trying to make your own Custom Callouts: https://github.com/robertmryan/CustomMapViewAnnotationCalloutSwift
You can also use this Cocoapod for custom callouts: https://github.com/okhanokbay/MapViewPlus