2017-05-31 84 views
1

如何在地圖視圖中更改註記視圖的rightCalloutAccessoryView按鈕的圖像?我已經使用以下方法在註釋視圖中設置按鈕。在地圖視圖中更改註記視圖的rightCalloutAccessoryView按鈕的圖像

annotationView!.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) 

(annotationView?.rightCalloutAccessoryView as! UIButton).setImage(UIImage(named: "abc"), for: .normal)

我也試圖與自定義按鈕,它不會改變

+0

它可能是有趣的。也許。 https://stackoverflow.com/questions/43407978/how-to-add-two-or-more-buttons-to-annotationview-mk​​annotationview –

回答

0

嘗試這樣的方式來創建Button,設置image並設置ButtonrightCalloutAccessoryView

let button = UIButton(frame: CGRect(x: 0, y: 0, width: 20, height: 20)) 
button.setImage(UIImage(named: "abc"), for: .normal) 
annotationView!.rightCalloutAccessoryView = button 
0

SWIFT 3.0 試試這個
您可以在標註設置服務器URL圖像。

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? { 
     marker.tracksInfoWindowChanges = true 
     let CustomWindowDisplay:CustomWindow = Bundle.main.loadNibNamed("View", owner: self, options: nil)![0] as! CustomWindow 
     let arrImages:NSArray = (dictDataOfPropertyData.value(forKey: "property_images") as? NSArray)! 
     if arrImages.count != 0{ 
      let strImage:String = (arrImages1.object(at: 0) as! NSDictionary).value(forKey: "property_photo") as! String 

      let urlofImg:NSURL = NSURL.init(string: strImage)! 
      CustomWindowDisplay.imgPropertyPhoto.sd_setImage(with: urlofImg as URL, placeholderImage: UIImage(named: "placeholder_main_list.png"), options: .highPriority) 
     } 
    }