我有一个视图,我以编程方式在viewDidLoad
. 该标签上的文字模糊不清。编码:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
[self setTitle:tAddSystemScreenTitle];
CGRect rect = CGRectMake(10,0,300,80);
UILabel *messageLabel = [[UILabel alloc] initWithFrame:rect];
[messageLabel setOpaque:NO];
if (shouldShowControlForRemoteAccess) {
[messageLabel setText:kRemoteAccessInfoMessage];
[messageLabel setNumberOfLines:2];
} else {
[messageLabel setText:kOneSystemAlreadyAssociatedAlertString];
[messageLabel setNumberOfLines:4];
rect.size.height += 30;
[messageLabel setFrame:rect];
rect = dataTable.frame;
rect.origin.y += 30;
rect.size.height -= 30;
[dataTable setFrame:rect];
}
NSLog(@"x: %f, y: %f, w: %f, h: %f", messageLabel.frame.origin.x, messageLabel.frame.origin.y, messageLabel.frame.size.width, messageLabel.frame.size.height);
[messageLabel setBackgroundColor:[UIColor clearColor]];
[messageLabel setShadowColor:[UIColor blackColor]];
[messageLabel setTextColor:[UIColor blackColor]];
[messageLabel setTextAlignment:UITextAlignmentLeft];
[messageLabel setShadowOffset:CGSizeMake(0,-1)];
[self.view addSubview:messageLabel];
NSLog(@"x: %f, y: %f, w: %f, h: %f", self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
[dataTable setScrollEnabled:NO];
[messageLabel release], messageLabel = nil;
}
当我检查帧值是什么时,我得到以下信息:
x: 10.000000, y: 0.000000, w: 300.000000, h: 80.000000
检查相同的self.view
获取:
x: 0.000000, y: 20.000000, w: 320.000000, h: 460.000000
在这个问题上我能找到的唯一 其他 问题表明我需要整数的帧,但正如你所看到的,我已经有了整数。我尝试了他们推荐的解决方案,CGRectIntegral(rect)
用来替换我刚刚拥有的所有地方rect
,但这不起作用。如何防止文字模糊?