Problem with a Retina Display Image
-
27-09-2019 - |
Question
I have a TabBarController app where the first tabBarItem is a NavigationController...
I assign programmatically an image background to the navController with this code:
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.If I try my app in the iPhone 4 simulator, the high definition image isn't loaded correctly and is showed the normal image...
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?
Thanks
Solution
I solved this problem using initWithPatternImage method of UIColor class.
I created and allocated an UIColor instance, I assigned to it an image and then I used it with background.
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"OverviewBg.png"]];
self.navigationController.view.backgroundColor = background;
Hope this can help other :)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow