I have long MKannotationView title text. Is there an easy way to give Text in title proper size?
reuseId = "Pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.image = UIImage(named:"pin")
pinView?.canShowCallout = true
pinView?.annotation
let button : UIButton = UIButton(type: UIButtonType.DetailDisclosure)
button.setImage(UIImage(named: "pin_arrow")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), forState:UIControlState.Normal)
pinView!.rightCalloutAccessoryView = button
let vw: UIView = UIView(frame: CGRectMake(0, 0, 40, 50))
let label: UILabel = UILabel(frame: CGRectMake(10, 0, 40, 50))
label.font = UIFont.init(name: "Roboto-Bold", size: 20)
label.textColor = UIColor(red:17/255.0, green:97/255.0, blue:172/255.0, alpha: 1.0)
label.numberOfLines = 1
for myObj in arrOfPinsOnMap where myObj.coordinate.latitude == pinView!.annotation!.coordinate.latitude && myObj.coordinate.longitude == pinView!.annotation!.coordinate.longitude && myObj.title == (pinView?.annotation?.title)!{
label.text = myObj.sale
if(myObj.sale != ""){
vw.addSubview(label)
if(label.text!.characters.count == 2){
vw.frame.size.width = 35
label.frame.size.width = 35
} else if(label.text!.characters.count == 3){
vw.frame.size.width = 47
label.frame.size.width = 47
} else if(label.text!.characters.count == 4){
label.frame.size.width = 67
vw.frame.size.width = 67
} else if(label.text!.characters.count > 4){
label.frame.size.width = 80
vw.frame.size.width = 80
}
pinView!.leftCalloutAccessoryView = vw
}
}
I have this method for showing View after TAP on pin. I can adjust my Label size on left side, but title remain fixed size. The title must be always visible.