2

I want to show some details, contain an image and related details when i click on the pin . i don't know how to customise bubble view.Can any one help me to find out a solution for this will be helpful.

Code below i tried but height is fixed not changing according to the size of the label

func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
    let reuseId = "pin"
    var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView

    if(pinView==nil){

        pinView=MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        pinView!.canShowCallout = true

        let base = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 300))
        base.backgroundColor = UIColor.lightGrayColor()

        let label1 = UILabel(frame: CGRect(x: 30, y: 10, width: 60, height: 300))
        label1.textColor = UIColor.blackColor()
        label1.text = "12 photos"
        base.addSubview(label1)
        pinView!.leftCalloutAccessoryView = base
        pinView!.pinColor = .Red

    }

    return pinView

}
  • You will need to use a custom `MKAnnotationView` subclass – Paulw11 Jul 31 '15 at 04:40
  • in custom classe ,how to set the frame size? . http://www.raywenderlich.com/87008/overlay-views-mapkit-swift-tutorial .i got example from above link. in AttractionAnnotationView where i give the width and height . – Subin K Kuriakose Jul 31 '15 at 06:40

0 Answers0