我正在将 UILabel 添加到用于加载目的的视图中.但是,添加后它变得模糊.奇怪的是,我在 UITableViewController 上加载的加载视图的代码几乎相同,并且在那里工作得很好.然而,UIViewController 之上的这个是模糊的.
I am adding a UILabel to a view meant for loading purposes. However, it gets blurry after I added it. The weird thing is that I just about the same code for an loading view which is loaded ontop of an UITableViewController and it works great there. Yet, this one on top of an UIViewController is blurry.
这是我的代码:
float x = (self.view.frame.size.width-20)/2;
float y = (self.view.frame.size.height-70)/2;
// Add loading and sub text
UILabel *loadingText = [[UILabel alloc] initWithFrame:CGRectMake(10, round(y+30), round(self.view.frame.size.width-20), 21)];
[loadingText setTextAlignment:UITextAlignmentCenter];
[loadingText setNumberOfLines:0];
[loadingText setFont:[UIFont systemFontOfSize:17]];
[loadingText setText:NSLocalizedString(@"Please wait...
We are processing your request", @"LoadingPage")];
[loadingText sizeToFit];
[loadingText setBackgroundColor:[UIColor clearColor]];
[loadingText setCenter:self.view.center];
[loadingText setTag:2];
[view addSubview:loadingText];
你的标签很模糊,因为框架使用了浮点数.
Your label is blurry because the frame is using floating numbers.
要强制为你的框架设置整数值:
To force integers value for your frame just do :
[loadingText setFrame:CGRectIntegral(loadingText.frame)];
您也可以将构成框架的所有值转换为 int
,但 CGRectIntegral
会为您完成所有工作.
You could also cast all your values composing your frame to int
, but CGRectIntegral
does all the job for you.
这篇关于以编程方式添加时模糊 UILabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!