古いiPhone画面と新しいiPhone画面の要素設定に関する多くの質問と回答に長い間携わってきましたが、いくつかのアイデアも得ました. 質問があります... iphone 320X480(iPhone)、iphone retina 3.5 インチ、4 インチ retina スクリーン用のアプリを準備しています。プログラムで設定したいウィンドウ(背景)のインスタンスの場合。タイトルバーが必要です。だから私がこれまでに行ったことは、画面サイズを
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f) {
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Do-568h@2x.png"]];
[self.view addSubview:backgroundImage];
[self.view sendSubviewToBack:backgroundImage];
} else {
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Do.png"]];
[self.view addSubview:backgroundImage];
[self.view sendSubviewToBack:backgroundImage];
}
最初のブロックはiPhone 5画面をチェックし(私は推測します)、2番目のブロックは通常の画面と網膜の両方の画面を設定し、320X480ピクセルの画像名 Do.png と640X960の画像名Do@2x.pngを配置します。iPhone と iPhone 3.5 (Retina) はシミュレーターで適切に表示されますが、iPhone 5 と同等であると思われる iPhone 4 (Retina) は正しく表示されません。どうすればいいのか教えてください...はい、Do-568h@2x.pngは640X1136です... .