我正在做一些简单的CALayer添加到UIView的测试。在我的主控制器类的iPhone 4的应用程序的,我实现了viewDidLoad
方法例如:iOS:self.view.bounds不填满整个窗口
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s", __PRETTY_FUNCTION__);
CALayer* ca = [[CALayer alloc] init];
[ca setBounds:self.view.bounds];
[ca setBackgroundColor:[[UIColor blueColor] CGColor]];
[self.view.layer addSublayer:ca];
}
蓝色背景仅占据屏幕的1/4。
我不知道这是因为我没有带Retina显示屏考虑吗?这种情况下的最佳做法是什么?
添加了这些调试消息:
NSLog(@"frame w:%f h:%f", self.view.frame.size.width, self.view.frame.size.height);
NSLog(@"bounds w:%f h:%f", self.view.bounds.size.width, self.view.bounds.size.height);
输出:
frame w:320.000000 h:460.000000
bounds w:320.000000 h:460.000000
'self.view.frame'的值是什么?你能证实吗? – 2011-05-22 06:38:34
@Deepak:{width:320,height:460}。这个问题本身也增加了调试输出。 – 2011-05-22 19:26:23