【发布时间】:2011-08-30 11:41:17
【问题描述】:
我正在做一些将 CALayer 添加到 UIView 的简单测试。在我的 iPhone 4 应用程序的主控制器类中,我实现了 viewDidLoad 方法:
- (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。
我想知道是不是因为我没有考虑到视网膜显示?在这种情况下,最佳做法是什么?
添加了这些调试消息:
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的值是多少?你能验证一下吗? -
@Deepak:它是 {width:320, height:460}。也将调试输出添加到问题本身。
标签: ios uiview uiviewcontroller calayer iphone-4