如何实现清晰渲染的旋转UILabel? [英] How do I achieve a clearly rendered rotated UILabel?

查看:165
本文介绍了如何实现清晰渲染的旋转UILabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示旋转的文字。 UILabel作为子视图添加到UIImageView上。 UIImageView具有通过CGAffineTransformMakeRotation(M_PI / 4.0)创建的转换。 UILabel的文字相当模糊。标题标签(在屏幕截图中,蓝色背景'What's ...')。



你知道如何设法使旋转的文字清晰呈现吗? / p>

我已经尝试过使用基于积分的框架(因为它将被旋转,这一点很重要),非清晰的背景颜色,并将标签设置为不透明= YES。仍然模糊。



谢谢!



解决方案

问题是你的标签是一半像素在帧的原点或旋转。旋转后检查框架原点,或尝试通过M_PI / 4.1(4.2,4.3,4.4,4.5 - 甚至测试值,如4.05 4.15 ..)旋转它,直到它正常渲染。同时检查UIImageView中UILabel的帧,可以在半像素原点添加ex。 {0.5,0.5}或其他..


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!

解决方案

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..

这篇关于如何实现清晰渲染的旋转UILabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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