UIViewにCALayerを追加する簡単なテストを行っています。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