How do I achieve a clearly rendered rotated UILabel?

强颜欢笑 提交于 2019-12-20 05:43:06

问题


I am trying to display rotated text. The UILabel is added as a subview on a UIImageView. The UIImageView has a transform created via say CGAffineTransformMakeRotation(M_PI/4.0). The text of the UILabel renders fairly blurry cf. the title label (in the screenshot, the blue background 'What's ...').

Do you know how I can manage to make the rotated text render clearly?

I've already tried using an integral-based frame (which matters little since it'll be rotated), a non-clear background color, and setting the label to opaque=YES. Still blurry.

Thanks!


回答1:


The problem is that your label is rendered in half pixel either in the origin of the frame or the rotation. Check the frame origin after rotation, or try to rotate it by M_PI/4.1 (4.2, 4.3, 4.4, 4.5 - even test values like 4.05 4.15..) until it renders normally. Also check the frame of the UILabel in the UIImageView, could be added at half pixel origin for ex. {0.5, 0.5} or something..



来源:https://stackoverflow.com/questions/10492367/how-do-i-achieve-a-clearly-rendered-rotated-uilabel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!