小编tuy*_* le的帖子


更改 MKMarkerAnnotationView 大小

如何改变MKMarkerAnnotationView尺寸?

我尝试设置annotationView.bounds.size = CGSize(width: 50, height: 50),但看起来大小没有改变。我还尝试打印视图的大小,看起来默认为 28,28

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
      guard annotation is MKPointAnnotation else { return nil }


      let annotationView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: Constant.Indentifier.mapPoint)
      annotationView.canShowCallout = true
      annotationView.animatesWhenAdded = true
      annotationView.glyphImage = UIImage(systemName: "house.fill")
      annotationView.glyphTintColor = .systemBlue
      annotationView.markerTintColor = .white
      print(annotationView.bounds.size) // defaulted to 28,28
      annotationView.bounds.size = CGSize(width: 50, height: 50) // Does not change bubble size
      return annotationView
}
Run Code Online (Sandbox Code Playgroud)

mapkit mkmapview mkmapviewdelegate swift

1
推荐指数
1
解决办法
3290
查看次数

标签 统计

c ×1

c++ ×1

mapkit ×1

mkmapview ×1

mkmapviewdelegate ×1

swift ×1