MKAnnotationView附件视图中的UILabel文本模糊 [英] Blurry UILabel text in accessory view of MKAnnotationView

查看:59
本文介绍了MKAnnotationView附件视图中的UILabel文本模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MKMapView中第一次选择图钉之后,将UILabel作为leftCalloutAccessoryView添加到MKAnnotationView中.添加标签不是问题:标注被选中并打开,这是将标签添加到标注视图的时候.标注会随着幻灯片动画自动向左扩展,并显示包括2行的新标签.不幸的是,在选择图钉之后,我需要添加标签,因为我首先需要有关该图钉的某些信息.

I'm trying to add a UILabel to an MKAnnotationView as a leftCalloutAccessoryView right after a pin got selected for the first time in the MKMapView. Adding the label is not a problem: The callout gets selected and opens, and this is when I add the label to the callout view. The callout gets automatically expanded to the left with a slide animation, and the new label including 2 lines is shown. Unfortunately I need to add the label after the Pin got selected because I need certain information about that Pin first.

现在的问题是,此标签中的文本有些模糊",就像未正确呈现一样.当我取消选择标注并再次选择它时,一切都将正确绘制.

The problem now is that the text in this label is somewhat "blurry", like it is not rendered correctly. When I deselect the callout and select it again, everything is drawn correctly.

这是我添加标签的方式:
在创建MKPinAnnotationView的过程中,我注册为视图的"selected"属性的观察者,因为没有选择引脚的委托方法.当在视图中选择图钉时,我的观察器方法将触发,并简单地将文本标签添加到视图中. (使用2行,清晰的背景色和加粗的白色系统字体创建UILabel,设置leftCalloutAccessoryView,释放标签).我尝试了setNeedsDisplay,setNeedsLayout和其他一些功能,但是无论如何,标签中的文本仍然模糊,直到第二次选择Pin为止.

This is the way I add the label:
During creation of the MKPinAnnotationView I register as an observer for the "selected" property of the view, since there is no delegate method for the selection of the pin. When the pin is selected in the view, my observer method fires and simply adds the text label to the view. (create UILabel with 2 lines, a clear background color and a bold white system font, set the leftCalloutAccessoryView, release the label). I tried setNeedsDisplay, setNeedsLayout and several other things, but no matter what, the text is still blurry in the label until the Pin is selected for the second time.

有什么主意,我可以如何正确绘制此标签而又不会模糊吗?

Any idea how I can get this Label to be drawn correctly without beeing blurry?

提前谢谢!

推荐答案

您确定标签位于像素边界上吗?当我以编程方式计算标签框架时没有看到模糊性,而没有考虑到我的计算可能会为原点返回非整数值.

Are you sure your label is being located on a pixel boundary? I've seen blurryness when I've calculated a label frame programmatically and not taken into account that my calculations could return a non-integer value for the origin.

这篇关于MKAnnotationView附件视图中的UILabel文本模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆