ios - How to change height of Annotation callout window Swift -
how change size of annotation callout window on map in swift. tried make bigger cgsize on each of component of right , left view without success height of view in end still same.
here code:
func mapview(mapview: mkmapview, viewforannotation annotation: mkannotation) -> mkannotationview? { print("delegate called") if !(annotation custompointannotation) { return nil } let reuseid = "test" var anview = mapview.dequeuereusableannotationviewwithidentifier(reuseid) if anview == nil { anview = mkannotationview(annotation: annotation, reuseidentifier: reuseid) selectedustanova = (annotation as! custompointannotation).ustanova anview!.canshowcallout = true } else { anview!.annotation = annotation } //set annotation-specific properties **after** //the view dequeued or created... let cpa = annotation as! custompointannotation anview!.image = uiimage(named:cpa.imagename) return anview } func mapview(mapview: mkmapview, didselectannotationview view: mkannotationview) { let button : uibutton = uibutton(type: uibuttontype.custom) uibutton let image = uiimage(named: "telephone") button.layer.cornerradius = 10 button.layer.backgroundcolor = uicolor.whitecolor().cgcolor button.layer.maskstobounds = true button.setbackgroundimage(image, forstate: uicontrolstate.normal) button.frame = cgrectmake(0, 0, 35, 200) button.addtarget(self, action: "buttonclicked:", forcontrolevents: uicontrolevents.touchupinside) let labeltitle : uilabel = uilabel(frame: cgrectmake(20,0,150,50)) labeltitle.text = selectedustanova!.ime let labelsubtitle : uilabel = uilabel(frame: cgrectmake(20,50,150,100)) var ustanovaopis = "" if selectedustanova!.opis != nil{ ustanovaopis+=selectedustanova!.opis!+"\n" } if selectedustanova!.telefon != nil{ ustanovaopis+=selectedustanova!.telefon! } labelsubtitle.text = ustanovaopis let leftcav : uiview = uiview(frame: cgrectmake(0,0,250,250)); let leftcav2: uiview = uiview(frame: cgrectmake(0,0,250,250)); let imageb = uiimage(named: "bigbutton") let imageview : uiimageview = uiimageview(frame: cgrectmake(0,0,300,300)) imageview.image = imageb; leftcav.addsubview(imageview) leftcav.addsubview(labeltitle) leftcav.addsubview(labelsubtitle) view.leftcalloutaccessoryview = leftcav; view.rightcalloutaccessoryview = leftcav2; }
is there chance of making view bigger tried changing sizes of left , right callout accessory view without success far.
if interested in changing height of annotation callout here simple way. , making height 200 units.
func mapview(mapview: mkmapview, viewforannotation annotation: mkannotation) -> mkannotationview? { if annotation mkuserlocation { return nil } let reuseid = "pin" var pinview = mapview.dequeuereusableannotationviewwithidentifier(reuseid) as? mkpinannotationview if pinview == nil { pinview = mkpinannotationview(annotation: annotation, reuseidentifier: reuseid) pinview!.canshowcallout = true pinview!.animatesdrop = true pinview!.pintintcolor = uicolor.blackcolor() } pinview!.detailcalloutaccessoryview = self.configuredetailview(pinview!) return pinview } func configuredetailview(annotationview: mkannotationview) -> uiview { let snapshotview = uiview() let views = ["snapshotview": snapshotview] snapshotview.addconstraints(nslayoutconstraint.constraintswithvisualformat("v:[snapshotview(200)]", options: [], metrics: nil, views: views)) //do work return snapshotview }
Comments
Post a Comment