2017-05-31 39 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) 
     } 
    } 
相关问题