gpt4 book ai didi

objective-c - 调整后的 UIImage 质量差

转载 作者:行者123 更新时间:2023-11-29 11:11:32 25 4
gpt4 key购买 nike

我正在尝试创建一个同时兼容 Retina 和非 Retina 显示器的应用程序。我正在使用高分辨率图像并让操作系统将它们缩小以用于非视网膜显示器。

图像命名为 xxx@2x.png 并且我使用相同的名称加载。这有效,并且图像在两种设备类型上以相同的相对大小显示。不幸的是,非视网膜显示器上调整大小后的图像质量远非理想。

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

遗产:

enter image description here

最佳答案

如果您自己调整图像大小,并将它们保存为 xxx.png 和 xxx@2x.png,那么您可以将它们用作“xxx”,iOS 将在使用 Retina 显示屏时自动使用 @2x 版本。

关于objective-c - 调整后的 UIImage 质量差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11351929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com