我正在尝试通过以下代码将图像放在导航项的右侧按钮上
//Add image to right bar button in navigation bar
UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"refresh.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(getData)];
self.navigationItem.rightBarButtonItem = rightBarButton;
[rightBarButton release];
图像 I 的尺寸为 52 X 52 像素。 如果我只是将图像添加到按钮中而不改变大小,我将得到不成比例的显示,如下所示
但是,如果我在添加到按钮之前尝试缩小图像(18 X 18 像素),图像在 iPhone 视网膜显示屏上看起来会很模糊
iPhone 视网膜显示屏的标签栏也会出现这种情况。
有什么方法可以在按钮或选项卡中使用大图像而不会出现不成比例的显示?或者有没有办法保持图像的分辨率?
最佳答案
您需要创建两个图形资源,一个为正常大小,另一个为视网膜大小加倍,并在文件名中添加 @2x。您可以在以下位置阅读更多信息:
关于objective-c - Objective-C : How to maintain image resolution/quality in navigation buttons and tab bars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6815010/