Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

使用大哥这个库,发现了会有uilabel和uibutton文字虚化的问题 #37

Closed
kchtin opened this issue May 26, 2017 · 1 comment
Closed

Comments

@kchtin
Copy link

kchtin commented May 26, 2017

当设置一个uilabel或者uibutton的sizetofit( || wrapContentSize = yes)的时候,再添加到布局中,发现文字会有虚化模糊效果;

@youngsoft youngsoft reopened this May 31, 2017
@youngsoft
Copy link
Owner

youngsoft commented May 31, 2017

您好! 这个问题已经在新发布的1.3.8中修复解决。UILabel出现字迹模糊的原因并不是MyLayout本身的问题,而是系统的问题。原因就是当UILabel对象在布局时只要其frame中的origin部分的值是小数,且小到无法对应到相应的物理像素点时就会出现字迹模糊的情况。

举例来说:在一个retina屏幕的设备中,一个设备逻辑点对应2个物理像素。因此0.5个设备逻辑点对应的就是1个物理像素。这也就要求每个视图的frame的值的所有部分都应该是0.5的倍数。而当某个frame值中的某个部分比如origin.y被设置为.13或者.7时那么这个小数值将可能无法正确的映射到真实的物理像素的位置。从而导致在显示时出现模糊的情况。一个解决的方法是我们将UILabel的frame值都统一转化为整数,这可以通过CGRectIntegral来将CGRect转化为最接近的整数。另外一个就是借助MyDimeScale类中的roundRect,roundNumber, roundSize, roundPoint这几个方法来将小数设备点转化为可表示为物理像素的最小设备逻辑点值。在新版本中采用的是后者的解决方法,目的是为了和计算出的frame更加接近。

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants