简体   繁体   English

视网膜显示图像出现问题

[英]Problem with a Retina Display Image


I have a TabBarController app where the first tabBarItem is a NavigationController... 我有一个TabBarController应用程序,其中第一个tabBarItem是NavigationController ...
I assign programmatically an image background to the navController with this code: 我使用以下代码以编程方式将图像背景分配给navController:

self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"OverviewBg.png"]];
The "OverviewBg.png" image is the exact size of the view between tabBar and NavBar. “ OverviewBg.png”图像是tabBar和NavBar之间的视图的确切大小。
If I try my app in the iPhone 4 simulator, the high definition image isn't loaded correctly and is showed the normal image... 如果我在iPhone 4模拟器中尝试我的应用,则高清晰度图像未正确加载,并显示为正常图像...

How can I solve this mistake? 我该如何解决这个错误? The best way to use colorWithPatternImage method is use an image with the exact size of the view or a pattern image? 使用colorWithPatternImage方法的最佳方法是使用具有正确视图尺寸的图像还是图案图像?

Thanks 谢谢

I solved this problem using initWithPatternImage method of UIColor class. 我使用UIColor类的initWithPatternImage方法解决了此问题。
I created and allocated an UIColor instance, I assigned to it an image and then I used it with background. 我创建并分配了一个UIColor实例,为它分配了图像,然后将其与背景一起使用。

UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"OverviewBg.png"]];
self.navigationController.view.backgroundColor = background;

Hope this can help other :) 希望这可以帮助其他:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM