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;
}
網膜:
遺産: