4
如何在Swift中更改Map上Annotation標註窗口的大小。我試圖在右側和左側視圖的每個組件上製作更大的CGSize,但沒有任何成功。最終視圖的高度仍然相同。如何更改Annotation標註窗口的高度Swift
這裏是我的代碼:
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
print("delegate called")
if !(annotation is 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 is 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) as 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;
}
有沒有做更大的查看我試圖改變左右標註附屬視圖,但沒有成功迄今規模的機會。