MKMapView的Swift自定义标注

MKMapView的Swift自定义标注,第1张

概述我正在为mapview实现自定义标注视图.我得到了这个输出 对于我正在使用的注释视图 func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { let reuseId = "mapPin" var anView = mapView.de 我正在为mapvIEw实现自定义标注视图.我得到了这个输出

对于我正在使用的注释视图

func mapVIEw(mapVIEw: MKMapVIEw!,vIEwForAnnotation annotation: MKAnnotation!) -> MKAnnotationVIEw! {     let reuseID = "mapPin"   var anVIEw = mapVIEw.dequeueReusableAnnotationVIEwWithIDentifIEr(reuseID) as? CustomCalloutVIEw    if anVIEw == nil {    anVIEw=CustomCalloutVIEw(annotation: annotation,reuseIDentifIEr:reuseID)        anVIEw!.image = UIImage(named:"mappin.png")        let button : UIbutton = UIbutton.buttonWithType(UIbuttonType.Detaildisclosure) as! UIbutton        button.addTarget(self,action: "buttonClicked:",forControlEvents: UIControlEvents.touchUpInsIDe)        anVIEw!.rightCalloutAccessoryVIEw=button     //anVIEw!.addSubvIEw(vIEwC)    mapVIEwControl.addAnnotation(annotation)    }    else {        anVIEw!.annotation = annotation    }    return anVIEw}

并d出标注视图

func mapVIEw(mapVIEw: MKMapVIEw!,dIDSelectAnnotationVIEw vIEw: MKAnnotationVIEw!){    var vIEwC:UIVIEw=UIVIEw(frame: CGRectMake(0,50,50))    vIEwC.backgroundcolor = UIcolor.blackcolor()   vIEw.addSubvIEw(vIEwC)    vIEwC.center = CGPointMake(vIEwC.bounds.size.wIDth*0.1,-vIEwC.bounds.size.height*0.5)}
解决方法 我得到了解决方案它的变化非常小.在vIEwForAnnotation中隐藏基本标注如下,

anVIEw!.canShowCallout = false
总结

以上是内存溢出为你收集整理的MKMapView的Swift自定义标注全部内容,希望文章能够帮你解决MKMapView的Swift自定义标注所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1002443.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存