Size image pin annotation

前端 未结 2 1086
梦如初夏
梦如初夏 2021-02-04 11:05

I put the personal image instead of the traditional red pin. When I open the map to display the pin, the image cover the entire map. Is there a maximum size of the pin image or

2条回答
  •  清酒与你
    2021-02-04 11:09

    I know there is an accepted answer already, but it did not work for me. Kosuke Ogawa is correct that there is no maximum size and you must instead do some resizing. However, I found that modifying the Frame on the MKAnnotationView produces better results.

    Kiko Lobo commented the solution that worked best for me, so all credit to him.

    Instead of doing anything with the UIImage, you only need to edit the MKAnnotationView. Kibo Lobo's comment:

    annotationView?.frame.size = CGSize(width: 30, height: 40)

    I actually did this in C# with Xamarin, that looks like this:

    annotationView.Frame = new CGRect(0,0,30,40);

    The accepted answer had no effect when implemented in Xamarin. Hope this helps anyone else encountering image scaling issues. The UIImage.Scale() method made the image very fuzzy, while modifying the Frame kept the quality the same.

提交回复
热议问题