2

Retina ディスプレイと非 Retina ディスプレイの両方と互換性のあるアプリケーションを作成しようとしています。私は高解像度の画像を使用しており、非網膜ディスプレイ用に OS に縮小させています。

画像の名前は xxx@2x.png で、同じ名前でロードします。これは機能し、画像は両方のデバイス タイプで同じ相対的なサイズで表示されます。残念ながら、Retina 以外のディスプレイでサイズ変更された画像の品質は理想とはほど遠いものです。

self.navigationItem.rightBarButtonItem.image = [localAssets imageAtPath:@"content/home/settings@2x.png"];

+ (UIImage*)imageAtPath:(NSString*)path;
{
    NSString* extension = [path pathExtension];
    path = [path stringByDeletingPathExtension];

    NSString* filePath = [[NSBundle mainBundle] pathForResource:[path lastPathComponent] 
                                                         ofType:extension 
                                                    inDirectory:[path stringByDeletingLastPathComponent]];
    UIImage* theImage = [UIImage imageWithContentsOfFile:filePath];

    if(!theImage)
    {
        NSLog(@"Error no file found at %@", [path stringByAppendingPathExtension:extension]);
    }
    return theImage;
}

網膜:

http://i.imgur.com/gmn1q.png

遺産:

ここに画像の説明を入力

4

1 に答える 1

2

自分で画像のサイズを変更し、xxx.png および xxx@2x.png として保存すると、それらを「xxx」として使用でき、Retina ディスプレイを使用する場合、iOS は自動的に @2x バージョンを使用します。

于 2012-07-05T20:17:58.317 に答える