我正在做一些簡單的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