Draw text in circle overlay

后端 未结 3 599
生来不讨喜
生来不讨喜 2020-11-30 11:23

I\'m trying to draw some circle overlays containing text on MKMapView. I have subclassed the MKCircleView, in which I put the following (based on this), but the text does no

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 12:02

    It is most likely that your text is drawn to a rectangle which is not visible.

    First thing I would do is try printing the values as %f instead of %lf, as those values look crazy. You should also print out the .size.width and .size.height for the two rects (mapRect and overallCGRect).

    If that doesn't lead you to a sensible rectangle definition, then try defining a CGRect yourself like CGRectMake(0,0,100,20) and see if the text draws.

    You can also try simply drawing a filled rectangle to the same overallCGRect that you are drawing your text into.

提交回复
热议问题