how to show multiple lines in MKAnnotation with autolayout?

后端 未结 6 1910
臣服心动
臣服心动 2020-12-30 17:21

i am using mapkit how i can multiple line in MKAnnotation view.

Every annotation there has title and subtitle. how i show sub title with

6条回答
  •  余生分开走
    2020-12-30 17:59

    Using auto layout you can type something like:

    let subtitleLabel = UILabel()
    subtitleLabel.text = "Location updated\n" + dateFormatter.string(from: date)
    subtitleLabel.numberOfLines = 0
    subtitleLabel.font = UIFont.systemFont(ofSize: 14)
    subtitleLabel.textColor = .lightGray
    subtitleLabel.setContentCompressionResistancePriority(.required, for: .vertical)
    
    annotationView?.detailCalloutAccessoryView = subtitleLabel
    

提交回复
热议问题